{"id":20132818,"url":"https://github.com/jcomo/immut","last_synced_at":"2026-02-14T13:01:31.312Z","repository":{"id":25299055,"uuid":"28725383","full_name":"jcomo/immut","owner":"jcomo","description":"An immutable container library for python","archived":false,"fork":false,"pushed_at":"2022-12-26T20:15:09.000Z","size":17,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-21T18:53:31.932Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcomo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-02T20:32:13.000Z","updated_at":"2020-06-06T14:18:15.000Z","dependencies_parsed_at":"2023-01-14T02:29:39.238Z","dependency_job_id":null,"html_url":"https://github.com/jcomo/immut","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jcomo/immut","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcomo%2Fimmut","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcomo%2Fimmut/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcomo%2Fimmut/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcomo%2Fimmut/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcomo","download_url":"https://codeload.github.com/jcomo/immut/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcomo%2Fimmut/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29444026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T12:43:28.304Z","status":"ssl_error","status_checked_at":"2026-02-14T12:43:14.160Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T20:55:16.012Z","updated_at":"2026-02-14T13:01:31.289Z","avatar_url":"https://github.com/jcomo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Immut\nAn immutable container library for Python\n\n![](https://travis-ci.org/jcomo/immut.svg?branch=master)\n\n## Use case\nThe intended use case for this library is to create named immutable container classes\nto use in an application. This would be particularly useful for value objects. Create\nan immutable container to hold a bunch of data with named fields and pass it freely\naround the application knowing that the contents will not be modified after creation.\n\n\n## Example usage\n```\npip install immut\n```\n\n```python\nfrom immut import ImmutableContainer\n\nResponseModel = ImmutableContainer('ResponseModel', 'message', 'code')\nresponse = ResponseModel(message='success')\nresponse.message  # returns 'success'\nresponse.code  # returns None\n\n# The fields can be anything\nu = User('jonathan')\nRequestModel = ImmutableContainer('RequestModel', 'user')\nrequest = RequestModel(user=u)\n```\n\n\n## API\nThe sole API is for creating a container.\n\n```python\nImmutableContainer(container_name, *fields)\n```\n\n**Parameters**\n* `container_name` the name of the class for the container (string). Generally, simply set it to the name of the variable\nyou are assigning to.\n* `fields` each field is a string representing the fields that this container will have\n\n**Returns**\nA dynamically generated immutable container\n\n**Behavior**\n* Trying to set a specified field on the immutable container after creation will raise an `AttributeError`.\n* Setting a *non-specified* field in the constructor will raise a `ValueError`\n  * Setting a non-specified field on the container after construction is allowed, but is not recommended as it is\n  outside the scope of the use case and is bad python programming practice in general.\n* Non-initialized fields in the constructor will return `None` when accessed.\n\n\n### Disclaimer\nI know this isn't the most pythonic or useful library in the world. It was conceived\nas a way for me to learn how meta classes work. However, it has its uses, and it is\nwell tested.\n\n##### Differences with `collections.namedtuple`\nThere are many similarities with this library and `collections.namedtuple`. The main difference is in the behavior with initialization. With a namedtuple, each defined attribute must be initialized in the constructor but with this container library, attributes are initialized to None by default if they are unspecified in the constructor.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcomo%2Fimmut","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcomo%2Fimmut","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcomo%2Fimmut/lists"}