=======
Dickens
=======
Additional Python decorators implementing the descriptor interface.
Use cases
=========
Like the built-in decorator, ``property``, these classes are initialized by and wrap a function, generally within the context of a class, in order to modify its behavior.
cached property
---------------
This decorator functions much like a read-only ``property``, with the difference that, upon access, it records its result in the instance's object data dictionary, which reference takes precedence in look-ups, thereby replacing itself for that object::
from descriptors import cachedproperty
@cachedproperty
def circumference(self):
return 2 * math.pi * self.radius
class property
--------------
A read-only ``property`` for class methods::
from descriptors import classproperty
@classproperty
def badpi(cls):
return 22 / 7
cached class property
---------------------
A class ``property``, which caches its result in the data dictionary of the class from which it was invoked, (under another name, so as not to interfere with inheritance of the property)::
from descriptors import cachedclassproperty
@cachedclassproperty
def badpi(cls):
return 22 / 7
class-only method
-----------------
A class method that **cannot** be accessed as an instance method::
from descriptors import classonlymethod
@classonlymethod
def circumference(cls, radius):
return 2 * cls.pi * radius
The class-only method *may* be overshadowed by instance data set under the same name.
Otherwise, instance access raises ``AttributeError`` (and such that it is forwarded to and *may* be handled by the instance's ``__getattr__``).
Installation
============
Dickens is a Python distribution, which may be installed via ``easy_install`` or ``pip``, *e.g.*::
pip install Dickens
...or, from source::
python setup.py install
Raw data
{
"_id": null,
"home_page": "https://github.com/dssg/dickens",
"name": "Dickens",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Center for Data Science and Public Policy",
"author_email": "datascifellows@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/be/88/2aca06f9396f1531ccbc7fed7444e984bf0f96842a7b2d1fde2a9e8a063e/Dickens-2.1.0.tar.gz",
"platform": null,
"description": "=======\nDickens\n=======\n\nAdditional Python decorators implementing the descriptor interface.\n\nUse cases\n=========\n\nLike the built-in decorator, ``property``, these classes are initialized by and wrap a function, generally within the context of a class, in order to modify its behavior.\n\ncached property\n---------------\n\nThis decorator functions much like a read-only ``property``, with the difference that, upon access, it records its result in the instance's object data dictionary, which reference takes precedence in look-ups, thereby replacing itself for that object::\n\n from descriptors import cachedproperty\n\n @cachedproperty\n def circumference(self):\n return 2 * math.pi * self.radius\n\nclass property\n--------------\n\nA read-only ``property`` for class methods::\n\n from descriptors import classproperty\n\n @classproperty\n def badpi(cls):\n return 22 / 7\n\ncached class property\n---------------------\n\nA class ``property``, which caches its result in the data dictionary of the class from which it was invoked, (under another name, so as not to interfere with inheritance of the property)::\n\n from descriptors import cachedclassproperty\n\n @cachedclassproperty\n def badpi(cls):\n return 22 / 7\n\nclass-only method\n-----------------\n\nA class method that **cannot** be accessed as an instance method::\n\n from descriptors import classonlymethod\n\n @classonlymethod\n def circumference(cls, radius):\n return 2 * cls.pi * radius\n\nThe class-only method *may* be overshadowed by instance data set under the same name.\n\nOtherwise, instance access raises ``AttributeError`` (and such that it is forwarded to and *may* be handled by the instance's ``__getattr__``).\n\nInstallation\n============\n\nDickens is a Python distribution, which may be installed via ``easy_install`` or ``pip``, *e.g.*::\n\n pip install Dickens\n\n...or, from source::\n\n python setup.py install",
"bugtrack_url": null,
"license": "",
"summary": "Additional decorators implementing the descriptor interface",
"version": "2.1.0",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "be882aca06f9396f1531ccbc7fed7444e984bf0f96842a7b2d1fde2a9e8a063e",
"md5": "62bfb241f87d5e16279abe68081f13fe",
"sha256": "aafde9820977738c43dccc8ac74cfa515baef4742fd221a836baa9d4b87671b5"
},
"downloads": -1,
"filename": "Dickens-2.1.0.tar.gz",
"has_sig": false,
"md5_digest": "62bfb241f87d5e16279abe68081f13fe",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3384,
"upload_time": "2023-04-11T19:17:45",
"upload_time_iso_8601": "2023-04-11T19:17:45.572732Z",
"url": "https://files.pythonhosted.org/packages/be/88/2aca06f9396f1531ccbc7fed7444e984bf0f96842a7b2d1fde2a9e8a063e/Dickens-2.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-11 19:17:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "dssg",
"github_project": "dickens",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "dickens"
}