{ "info": { "author": "Matthew Lefavor", "author_email": "mclefavor@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.0", "Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Topic :: Software Development", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "reprutils\n=========\n\nThis is a simple Python module for reducing the boilerplate code\ninvolved in writing ``__repr__`` methods. This code works for all\nPython versions from 2.6 to 3.3.\n\nThis software was written by Matthew Lefavor (mclefavor _at_ gmail.com).\nThe license for this software can be found in the LICENSE text file\naccompanying this distribution.\n\nInstallation\n------------\n\nDownload the reprutils source archive from PyPI. After downloading,\nunpack the archive and run the standard \"python setup.py install\" with\nyour favorite Python interpreter::\n\n my-shell$ tar -xf reprutils-1.0.tar.gz\n my-shell$ cd reprutils-1.0\n my-shell$ python setup.py install\n\nYou may need to use ``sudo`` for the last step, depending on the\nlocation of your python interpreter. This package is also installable\nvia ``pip``, and Windows users can use a graphical installer found on\nthe PyPI page.\n\nOverview and Examples\n---------------------\n\nIn Python, an object's ``__repr__`` method is supposed to return a\nstring giving a standard representation of the object. By convention,\nthe strings returned by a ``__repr__`` method should be (whenever\npossible) a valid Python expression that could return an equivalent\nobject. This means returning a string that looks like a call to the\nobject's constructor (fully qualified with the module name). But the\ncode to do so is typically repetitive and hard to read, particularly\nif you wish to want to dynamically access the object's module and class\nname. This module provides functions and descriptors for creating some\ncommon ``__repr__`` patterns to save time, improve code readability, and\npromote the good coding practice of creating ``__repr__`` methods for\nobjects (don't debug without one!).\n\nThe ``standard_repr`` function is a general-purpose function for\ncreating a constructor-formatted repr as described above. The user can\npass any arbitrary values to appear as arguments or keyword arguments to\nthe constructor. That said, most use cases don't require arbitrary\nvalues; the values to appear in the resulting string are attributes of\nthe object. This case is simplified by the `GetattrRepr` descriptor.\nExample usages of both are given below; for more information about\nnitty-gritty details (like the ordering of keyword arguments) and some\nsyntactic sugar, consult the docstrings for ``standard_repr`` and\n``GetattrRepr``.\n\nHere are two examples of basic usages of both ``standard_repr`` and\n``GetattrRepr``::\n\n >>> from reprutils import standard_repr, GetattrRepr\n >>> class DataPoint(object):\n ... \"\"\"Represents a single point of data.\"\"\"\n ... def __init__(self, time, value, units=None):\n ... \"\"\"Initialize the DataPoint.\n ...\n ... @param time: Time (in seconds) of the observation\n ... @param value: Recorded value at the time of the observation.\n ... @param units: Units of the measurement\n ...\n ... \"\"\"\n ... self.time = time\n ... self.value = value\n ... self.units = units\n ...\n ... __repr__ = GetattrRepr('time', 'value', units='units')\n ...\n >>> dp = DataPoint(1200, 5.3, units=\"Newtons\")\n >>> dp\n \"__main__.DataPoint(1200, 5.3, units='Newtons')\"\n >>> class DataPoint2(object):\n ... \"\"\"Represents a single point of data.\"\"\"\n ... def __init__(self, time, value, units=None):\n ... \"\"\"Initialize the DataPoint.\n ...\n ... @param time: Time (in seconds) of the observation\n ... @param value: Recorded value at the time of the observation.\n ... @param units: Units of the measurement\n ...\n ... \"\"\"\n ... self.time = time + 1800 # Correct timezone\n ... self.value = value - 2.5 # Correct for widget offset\n ... self.units = units\n ...\n ... def __repr__(self):\n ... \"\"\"Return a standard representation of the object.\"\"\"\n ... return standard_repr(self, [self.time - 7000, value + 2.5],\n ... [('units', self.units)])\n ...\n >>> dp = DataPoint2(24000, 2.6, units=\"Newtons\")\n >>> dp\n \"__main__.DataPoint2(24000, 2.6, units='Newtons')\"", "description_content_type": null, "docs_url": null, "download_url": "https://pypi.python.org/pypi/reprutils", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mlefavor/py-reprutils", "keywords": "reprutils,repr,__repr__", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "reprutils", "package_url": "https://pypi.org/project/reprutils/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/reprutils/", "project_urls": { "Download": "https://pypi.python.org/pypi/reprutils", "Homepage": "https://github.com/mlefavor/py-reprutils" }, "release_url": "https://pypi.org/project/reprutils/1.0/", "requires_dist": null, "requires_python": null, "summary": "Helper Functions for `__repr__` Methods", "version": "1.0" }, "last_serial": 4932216, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "2631db24e19952fc074ec718336abc59", "sha256": "8493be32ca482f202a36f075b1f179d19aaa5ccfa7ddf060dc29972518c2486b" }, "downloads": -1, "filename": "reprutils-1.0.macosx-10.6-intel.exe", "has_sig": false, "md5_digest": "2631db24e19952fc074ec718336abc59", "packagetype": "bdist_wininst", "python_version": "any", "requires_python": null, "size": 71723, "upload_time": "2013-04-17T18:00:24", "url": "https://files.pythonhosted.org/packages/7f/e8/3ad0cb15b9e7a79f9011c3e057477aaf92f8279faef333035cf5a67f33d5/reprutils-1.0.macosx-10.6-intel.exe" }, { "comment_text": "", "digests": { "md5": "7e2f21db6100d71f8a2e29c7e0c9bb9f", "sha256": "e234bfa606f19d1b0d0e1ce29ddaa2c50450bb4e9e3aa8446bb416e5fde8a92b" }, "downloads": -1, "filename": "reprutils-1.0.tar.gz", "has_sig": false, "md5_digest": "7e2f21db6100d71f8a2e29c7e0c9bb9f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6290, "upload_time": "2013-04-17T17:34:40", "url": "https://files.pythonhosted.org/packages/9f/56/b2210b182dc8f95ee8d0fe2352fe1a3b386ae88203eed6d8e529649a7c64/reprutils-1.0.tar.gz" }, { "comment_text": "", "digests": { "md5": "f68b7e8e6af2415c7af65511dee02da5", "sha256": "7e1775d14ca493ad9819401ed5c641af35dffadaadd49715aac11b6d3301d7e7" }, "downloads": -1, "filename": "reprutils-1.0.zip", "has_sig": false, "md5_digest": "f68b7e8e6af2415c7af65511dee02da5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8398, "upload_time": "2013-04-17T17:34:44", "url": "https://files.pythonhosted.org/packages/56/f5/18bb40d46e3cc55c3a46cdadd5a74fc9df0119d8e6de415da7301bea2db4/reprutils-1.0.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2631db24e19952fc074ec718336abc59", "sha256": "8493be32ca482f202a36f075b1f179d19aaa5ccfa7ddf060dc29972518c2486b" }, "downloads": -1, "filename": "reprutils-1.0.macosx-10.6-intel.exe", "has_sig": false, "md5_digest": "2631db24e19952fc074ec718336abc59", "packagetype": "bdist_wininst", "python_version": "any", "requires_python": null, "size": 71723, "upload_time": "2013-04-17T18:00:24", "url": "https://files.pythonhosted.org/packages/7f/e8/3ad0cb15b9e7a79f9011c3e057477aaf92f8279faef333035cf5a67f33d5/reprutils-1.0.macosx-10.6-intel.exe" }, { "comment_text": "", "digests": { "md5": "7e2f21db6100d71f8a2e29c7e0c9bb9f", "sha256": "e234bfa606f19d1b0d0e1ce29ddaa2c50450bb4e9e3aa8446bb416e5fde8a92b" }, "downloads": -1, "filename": "reprutils-1.0.tar.gz", "has_sig": false, "md5_digest": "7e2f21db6100d71f8a2e29c7e0c9bb9f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6290, "upload_time": "2013-04-17T17:34:40", "url": "https://files.pythonhosted.org/packages/9f/56/b2210b182dc8f95ee8d0fe2352fe1a3b386ae88203eed6d8e529649a7c64/reprutils-1.0.tar.gz" }, { "comment_text": "", "digests": { "md5": "f68b7e8e6af2415c7af65511dee02da5", "sha256": "7e1775d14ca493ad9819401ed5c641af35dffadaadd49715aac11b6d3301d7e7" }, "downloads": -1, "filename": "reprutils-1.0.zip", "has_sig": false, "md5_digest": "f68b7e8e6af2415c7af65511dee02da5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8398, "upload_time": "2013-04-17T17:34:44", "url": "https://files.pythonhosted.org/packages/56/f5/18bb40d46e3cc55c3a46cdadd5a74fc9df0119d8e6de415da7301bea2db4/reprutils-1.0.zip" } ] }