{ "info": { "author": "Ryan Kelly", "author_email": "ryan@rfk.id.au", "bugtrack_url": null, "classifiers": [], "description": "autoself: automagically add method definition boilerplate\r\n\r\nFirst, a disclaimer. Explicit self is good. Bytecode hacks are bad.\r\nPut them together and it's quite clear that THIS MODULE IS AN ABOMINATION!\r\nBut, it's a neat excursion into python's lower levels and if you *really*\r\n*really* want to save yourself some keystrokes (like, you're desperately\r\ntrying to hack into the Death Star's security system to override the trash\r\ncompactor as its cold metal jaws slowly squeeze you to a purple paste) then\r\nit can help you do that. But, stop and consider Guido's proclamation on\r\nthe matter:\r\n\r\n Having self be explicit is a *good thing*. It makes the code clear by\r\n removing ambiguity about how a variable resolves. It also makes the\r\n difference between functions and methods small.\r\n \"Things that will Not Change in Python 3000\":\r\n http://www.python.org/dev/peps/pep-3099/#core-language\r\n\r\nThis module is not about making 'self' implicit. It doesn't try to change\r\nthe way methods work, or make any semantic changes whatsoever. It does one\r\nsimple thing: automatically adds the boilerplate code to make a function do\r\nthe \"right thing\" when called as a method.\r\n\r\nIt provides a single function 'autoself'. Given a function as argument,\r\n'autoself' will return an equivalent function with the necessary boilerplate\r\nin place to act as a method. This will depend on the specifics of the\r\nfunction, and could mean:\r\n\r\n * Inserting 'self' as the zeroth argument\r\n * Inserting 'cls' as the zeroth argument, and wrapping with classmethod()\r\n * Wrapping with staticmethod() if 'self' and 'cls' are not used\r\n * Doing nothing, if it's not a proper function or is fine the way it is\r\n\r\nFor example, defining the method 'likes' using:\r\n\r\n def likes(self,ham,eggs):\r\n print self, \"likes\", ham, \"and\", eggs\r\n\r\nIs equivalent to defining it in the following way:\r\n\r\n def likes(ham,eggs):\r\n print self, \"likes\", ham, \"and\", eggs\r\n likes = autoself(likes)\r\n\r\nOr neater, using the @autoself decorator. Of course, this isn't going to\r\nsave you any typing! 'autoself' can also be applied to a class, and will\r\nautoselfify all functions in that class's dict:\r\n\r\n class HeapsLessTyping:\r\n def likes(ham,eggs):\r\n # This gets 'self' automatically added as zeroth argument\r\n print self, \"likes\", ham, \"and\", eggs\r\n def hates(spam):\r\n # This becomes a classmethod, with 'cls' added as zeroth argument\r\n print \"all\", cls, \"hate\", spam\r\n def meh(toast):\r\n # This becomes a staticmethod\r\n print toast, \"is boring\"\r\n HeapsLessTyping = autoself(HeapsLessTyping)\r\n\r\nWhen it becomes available (Python 2.6?), it will be even more convenient to\r\nuse this with the class decorator syntax.\r\n\r\nWant to save even more typing? 'autoself' can be used as a metaclass to\r\nwork its magic on all classes defined in a module:\r\n\r\n __metaclass__ = autoself\r\n\r\n class LookNoSelf:\r\n def __init__(my,special,args):\r\n self.my = my\r\n self.special = special\r\n self.args = args\r\n class FiveKeystrokesSaved:\r\n def __init__(this,works,great):\r\n self.this = this\r\n self.works = works\r\n self.great = great\r\n counter = 0\r\n def ClassMethodsSaveEvenMore():\r\n cls.counter += 1\r\n\r\nUsing this style, you can see a net saving in keystrokes with five method\r\ndefinitions or less!", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://www.rfk.id.au/software/autoself/", "keywords": "self cls method", "license": "Public Domain", "maintainer": "", "maintainer_email": "", "name": "autoself", "package_url": "https://pypi.org/project/autoself/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/autoself/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://www.rfk.id.au/software/autoself/" }, "release_url": "https://pypi.org/project/autoself/1.1.0/", "requires_dist": null, "requires_python": null, "summary": "Automagically add method definition boilerplate", "version": "1.1.0" }, "last_serial": 786630, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "733fdd70cd08d44f34bfe45c9a42ac39", "sha256": "a90eb7bcbfc934eb927553f07f5125cf0961429e9a3eaecb245c1caae242223f" }, "downloads": -1, "filename": "autoself-1.0.0-py2.4.egg", "has_sig": false, "md5_digest": "733fdd70cd08d44f34bfe45c9a42ac39", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 12322, "upload_time": "2007-09-12T09:52:02", "url": "https://files.pythonhosted.org/packages/49/c0/a12aeb2a13323f720a63115d4c49bf4845713b0aeac9ca8b82ee5c2878bf/autoself-1.0.0-py2.4.egg" }, { "comment_text": "", "digests": { "md5": "95af28c6249972edb5d6f3629ca52fc0", "sha256": "ad324c5fd4a47c3d45268ce443daddfdf71ec5c846f5c32f7a9106c04a015246" }, "downloads": -1, "filename": "autoself-1.0.0-py2.5.egg", "has_sig": false, "md5_digest": "95af28c6249972edb5d6f3629ca52fc0", "packagetype": "bdist_egg", "python_version": "2.5", "requires_python": null, "size": 12252, "upload_time": "2007-09-12T06:14:30", "url": "https://files.pythonhosted.org/packages/ce/04/43772ffd81ceb2286ad2801e90a4ea88a7f927d765a3f2118676bdd4a094/autoself-1.0.0-py2.5.egg" }, { "comment_text": "", "digests": { "md5": "aaac64e0a59916d6ebfc96550cc9c945", "sha256": "f2f2161305feb171962de19c43c1f19984ee14438d6f7ca28ea6b3df190490be" }, "downloads": -1, "filename": "autoself-1.0.0.tar.gz", "has_sig": false, "md5_digest": "aaac64e0a59916d6ebfc96550cc9c945", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5202, "upload_time": "2007-09-12T06:14:28", "url": "https://files.pythonhosted.org/packages/4e/10/d00a07da4f8abcf6d200c56b0101d0f027d330a63907d816f900c156b65c/autoself-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "f2806cdd3316423bf0a46d64b9dfea89", "sha256": "bac4f60ef2b0e03ae752edd0f2639035bd28d2d6438de441f14af5d645212b9e" }, "downloads": -1, "filename": "autoself-1.1.0-py2.4.egg", "has_sig": false, "md5_digest": "f2806cdd3316423bf0a46d64b9dfea89", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 13946, "upload_time": "2007-09-18T02:19:27", "url": "https://files.pythonhosted.org/packages/41/28/647e7b49d254bc4acddfda622b633f47e36e14a4c5233502ca3df51cf764/autoself-1.1.0-py2.4.egg" }, { "comment_text": "", "digests": { "md5": "26846580b1de17c8d610d4258cb1f656", "sha256": "b3dc404977dae49ff64aaa8c3c72d94a6bec18bd7df02ec87f10a040e49378f0" }, "downloads": -1, "filename": "autoself-1.1.0-py2.5.egg", "has_sig": false, "md5_digest": "26846580b1de17c8d610d4258cb1f656", "packagetype": "bdist_egg", "python_version": "2.5", "requires_python": null, "size": 13840, "upload_time": "2007-09-18T02:19:19", "url": "https://files.pythonhosted.org/packages/6b/4c/283a54b52f7593875055e12ebef36ad52c3f51670494517debc550c0493e/autoself-1.1.0-py2.5.egg" }, { "comment_text": "", "digests": { "md5": "b09b3e360c793dd40e43837b870d54de", "sha256": "7205196aa44c6cd9cfcd41b5673a5266b3496280dc69279b463e310b2e9e16bc" }, "downloads": -1, "filename": "autoself-1.1.0.tar.gz", "has_sig": false, "md5_digest": "b09b3e360c793dd40e43837b870d54de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5824, "upload_time": "2007-09-18T02:19:15", "url": "https://files.pythonhosted.org/packages/0b/cd/669955dc4a8d7682d651425fb09e55b1b75e84ae4e1fcde9468a5befd08c/autoself-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f2806cdd3316423bf0a46d64b9dfea89", "sha256": "bac4f60ef2b0e03ae752edd0f2639035bd28d2d6438de441f14af5d645212b9e" }, "downloads": -1, "filename": "autoself-1.1.0-py2.4.egg", "has_sig": false, "md5_digest": "f2806cdd3316423bf0a46d64b9dfea89", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 13946, "upload_time": "2007-09-18T02:19:27", "url": "https://files.pythonhosted.org/packages/41/28/647e7b49d254bc4acddfda622b633f47e36e14a4c5233502ca3df51cf764/autoself-1.1.0-py2.4.egg" }, { "comment_text": "", "digests": { "md5": "26846580b1de17c8d610d4258cb1f656", "sha256": "b3dc404977dae49ff64aaa8c3c72d94a6bec18bd7df02ec87f10a040e49378f0" }, "downloads": -1, "filename": "autoself-1.1.0-py2.5.egg", "has_sig": false, "md5_digest": "26846580b1de17c8d610d4258cb1f656", "packagetype": "bdist_egg", "python_version": "2.5", "requires_python": null, "size": 13840, "upload_time": "2007-09-18T02:19:19", "url": "https://files.pythonhosted.org/packages/6b/4c/283a54b52f7593875055e12ebef36ad52c3f51670494517debc550c0493e/autoself-1.1.0-py2.5.egg" }, { "comment_text": "", "digests": { "md5": "b09b3e360c793dd40e43837b870d54de", "sha256": "7205196aa44c6cd9cfcd41b5673a5266b3496280dc69279b463e310b2e9e16bc" }, "downloads": -1, "filename": "autoself-1.1.0.tar.gz", "has_sig": false, "md5_digest": "b09b3e360c793dd40e43837b870d54de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5824, "upload_time": "2007-09-18T02:19:15", "url": "https://files.pythonhosted.org/packages/0b/cd/669955dc4a8d7682d651425fb09e55b1b75e84ae4e1fcde9468a5befd08c/autoself-1.1.0.tar.gz" } ] }