{ "info": { "author": "Andrew Seier", "author_email": "andseier@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: Freely Distributable", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Utilities" ], "description": "The Immutable Package\n=====================\n\nThis package is an *exceedingly* simple wrapper around the builtin\n``namedtuple`` from the ``collections`` package.\n\nIt allows you to instantiate via a ``tuple`` or via ``kwargs``. It\nsimplifies the case where you know ahead of time what the values of an\n``Immutable`` should be and you just need to instantiate it once.\n\nInstall\n-------\n\n``pip install immutable``\n\nDetails\n-------\n\n``namedtuple``\n~~~~~~~~~~~~~~\n\nThe ``namedtuple`` is a Python ``builtin`` that allows you to\ninstantiate an object as follows:\n\n.. code:: python\n\n from collections import namedtuple\n\n TupleFactory = namedtuple('ATuple', ['using', 'these', 'attrs'])\n ATuple = TupleFactory('first', these='second', attrs='third')\n ATuple # ATuple(using='first', these='second', attrs='third')\n\n # dot-access attributes\n ATuple.using # 'first'\n Atuple.these # 'second'\n ATuple.attrs # 'third'\n\n # index-access attributes\n ATuple[0] # 'first'\n ATuple[1] # 'second'\n ATuple[2] # 'third'\n ATuple[-1] # 'third'\n\n # the class name is as specified in creating the original factory\n ATuple.__class__.__name__ # 'ATuple'\n\n``ImmutableFactory``\n~~~~~~~~~~~~~~~~~~~~\n\nReplicate ``namedtuple`` functionality\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThe ImmutableFactory is just a thin wrapper that allows you to do this\nin one step:\n\n.. code:: python\n\n from immutable import ImmutableFactory\n\n attributes = (('using', 'first'), ('these', 'second'), ('attrs', 'third'))\n\n # don't worry about the extra kwargs for now :)\n ATuple = ImmutableFactory.create(attributes, keys=False, values=False, items=False)\n ATuple # Immutable(using='first', these='second', attrs='third')\n\n # dot-access attributes\n ATuple.using # 'first'\n Atuple.these # 'second'\n ATuple.attrs # 'third'\n\n # index-access attributes\n ATuple[0] # 'first'\n ATuple[1] # 'second'\n ATuple[2] # 'third'\n ATuple[-1] # 'third'\n\n # the class name is *always* `Immutable` now\n ATuple.__class__.__name__ # 'Immutable'\n\nSome extra bells and whistles (don't get too excited)\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nMost of the time, we don't care about the *order*. This allows us to\ninstantiate in a *much* cleaner style:\n\n.. code:: python\n\n from immutable import ImmutableFactory\n\n ATuple = ImmutableFactory.create(using='first', these='second', attrs='third',\n keys=False, values=False, items=False)\n\n # note that there's no predictable order here\n ATuple # Immutable(these='second', using='first', attrs='third')\n\n # dot-access attributes\n ATuple.using # 'first'\n Atuple.these # 'second'\n ATuple.attrs # 'third'\n\n # doesn't really make sense to index-access attributes now, so don't.\n\n # the class name is *always* `Immutable` now\n ATuple.__class__.__name__ # 'Immutable'\n\nAdditionally, it's helpful to have dict-like ``keys``, ``values``, and\n``items``. These\n\nNotes\n~~~~~\n\nNote if you use a *mutable* as a value for an attribute of an\n``Immutable`` object, you'll be able to change it. If this wasn't the\ncase, the ``ImmutableFactory`` would need to mutate your input data--not\nnice.\n\n.. code:: python\n\n from immutable import ImmutableFactory\n\n ATuple = ImmutableFactory.create(mutable=['a', 'list'])\n ATuple.mutable # ['a', 'list']\n ATuple.mutable.append('can change!')\n ATuple.mutable # ['a', 'list', 'can change!']", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://plot.ly/theengineear/immutable", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "immutable", "package_url": "https://pypi.org/project/immutable/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/immutable/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://plot.ly/theengineear/immutable" }, "release_url": "https://pypi.org/project/immutable/0.0.2/", "requires_dist": null, "requires_python": null, "summary": "Simple immutable object factory", "version": "0.0.2" }, "last_serial": 1817751, "releases": { "0.0.1": [], "0.0.2": [ { "comment_text": "", "digests": { "md5": "31ae43432b631aa8d38f5564f1e602ea", "sha256": "2b7d281e4e1cf782082bb02eeb8898a3bac76b237abec0ddb7c3fb4bca408670" }, "downloads": -1, "filename": "immutable-0.0.2.tar.gz", "has_sig": false, "md5_digest": "31ae43432b631aa8d38f5564f1e602ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6126, "upload_time": "2015-11-15T19:55:51", "url": "https://files.pythonhosted.org/packages/cd/d1/94ebd56b425c8dc06f2a887a8b7333950ac7265de790a561e3fa0db85c45/immutable-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "31ae43432b631aa8d38f5564f1e602ea", "sha256": "2b7d281e4e1cf782082bb02eeb8898a3bac76b237abec0ddb7c3fb4bca408670" }, "downloads": -1, "filename": "immutable-0.0.2.tar.gz", "has_sig": false, "md5_digest": "31ae43432b631aa8d38f5564f1e602ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6126, "upload_time": "2015-11-15T19:55:51", "url": "https://files.pythonhosted.org/packages/cd/d1/94ebd56b425c8dc06f2a887a8b7333950ac7265de790a561e3fa0db85c45/immutable-0.0.2.tar.gz" } ] }