{ "info": { "author": "kai zhu", "author_email": "kaizhu256@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: Education", "Intended Audience :: End Users/Desktop", "Natural Language :: English", "Operating System :: POSIX", "Operating System :: POSIX :: Linux", "Operating System :: Unix", "Programming Language :: C", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.0", "Programming Language :: Python :: 3.1", "Topic :: Education", "Topic :: Education :: Testing", "Topic :: Software Development", "Topic :: Software Development :: Assemblers", "Topic :: Software Development :: Build Tools", "Topic :: Software Development :: Code Generators", "Topic :: Software Development :: Compilers", "Topic :: Software Development :: Disassemblers", "Topic :: Software Development :: Interpreters", "Topic :: Software Development :: Pre-processors", "Topic :: Software Development :: Testing", "Topic :: System :: Emulators", "Topic :: Utilities" ], "description": "################################################################################\r\nthis is a pure python3.0 module.\r\npseudomethod is an extended language feature for python3.0.\r\nit adds the \"..\" notation for calling regular functions as methods.\r\nthis allows u to extend any class or object on-the-fly w/o subclassing\r\n& enhances python's functional programming ability.\r\npseudomethods r liberally used in the py3to2 application asciiporn\r\n(http://pypi.python.org/pypi/asciiporn)\r\n\r\na method is normally called by the \".\" notation:\r\n\r\n class Foo:\r\n def method(self, *args, **kwds):\r\n ...\r\n Foo().method(*args, **kwds)\r\n\r\npseudomethod allows u to call normal functions on-the-fly as methods\r\nusing the \"..\" notation:\r\n\r\n def function(self, *args, **kwds):\r\n ...\r\n class Foo: pass\r\n Foo()..function(*args, **kwds) ## function temporarily bound to Foo\r\n\r\nthe only requirement for a function to b a pseudomethod is that it must accept\r\n@ least one argument (the self/type object its passed to b temporarily bound).\r\n\r\nwhat actually happens is just simple rearrangement of symbols:\r\n\r\n a( b, *args, **kwds ) <==> b ..a( *args, **kwds )\r\n a( b( c( d ) ) ) <==> d ..c() ..b() ..a()\r\n\r\nin this respect, the \"..\" notation could b thought of as a \"flattener\",\r\nremoving nesting of the 1st argument, & allowing an elegant style of\r\nfunctional programming in python\r\n\r\nfor a real-world application using pseudomethod, check out the py3to2\r\napplication asciiporn @:\r\n\r\n http://pypi.python.org/pypi/asciiporn\r\n\r\nAUTHOR:\r\n kai zhu\r\n kaizhu256@gmail.com\r\n\r\nREQUIREMENTS:\r\n- python3.0 or higher\r\n- for python2.6, see py3to2 (which has pseudomethods enabled by default)\r\n\r\nINSTALL:\r\n python3.0 setup.py install\r\n python3.0 setup.py dev --quicktest\r\n\r\nAPI:\r\n type \"help(pseudomethod)\" for more details\r\n pseudomethod module:\r\n - parser - string & ast parser for pseudomethod syntax\r\n - importer - import hook for handling scripts containing pseudomethod\r\n syntax\r\n\r\nMAGIC\r\n 1 pseudomethod first initializes an import hook\r\n 2 add the MAGIC LINE:\r\n\r\n from __future__ import pseudomethod\r\n\r\n to ur script & the import hook will take care of the rest\r\n\r\nUSAGE:\r\n start up the python3.0 interpreter & import pseudomethod:\r\n $ python3.0\r\n\r\n Python 3.0rc2 (r30rc2:67114, Nov 9 2008, 21:30:06)\r\n [GCC 3.4.6 20060404 (Red Hat 3.4.6-10)] on linux2\r\n Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n >>>\r\n >>> import pseudomethod\r\n\r\n try out this simple pseudomethod script:\r\n ################################################################\r\n ## copy this to file pseudomethod_ex1.py\r\n from __future__ import pseudomethod\r\n\r\n def add_to_self(self, x): return self + x\r\n\r\n print(\r\n \"ab\" ..add_to_self ( \"c\" ),\r\n bytearray(b\"ab\") ..add_to_self ( b\"c\" ),\r\n 1 ..add_to_self ( 2 ),\r\n [1, 2] ..add_to_self ( [3] ),\r\n )\r\n ################################################################\r\n >>>\r\n >>> import pseudomethod_ex1\r\n abc bytearray(b'abc') 3 [1, 2, 3]\r\n\r\n for functional-style programming,\r\n pseudomethods are quite useful for cleaning up ugly nested arguments:\r\n ################################################################\r\n ## copy this to file pseudomethod_ex2.py\r\n from __future__ import pseudomethod\r\n\r\n ## ugly, Ugly, UGLY !!!\r\n print(\r\n list(\r\n zip(\r\n sorted(\r\n [(2,3), (0,4), (1,5)],\r\n key = lambda x: x[0]\r\n ),\r\n range(2, 5)\r\n )\r\n )\r\n )\r\n\r\n ## elegant ^_^\r\n [(2,3), (0,4), (1,5)] ..sorted(key = lambda x: x[0]) \\\r\n ..zip(range(2, 5)) \\\r\n ..list() \\\r\n ..print()\r\n ################################################################\r\n >>>\r\n >>> import pseudomethod_ex2\r\n [((0, 4), 2), ((1, 5), 3), ((2, 3), 4)]\r\n [((0, 4), 2), ((1, 5), 3), ((2, 3), 4)]\r\n >>>\r\n\r\n################################################################################\r\nMECHANISM:\r\n 1 this module installs an import hook to detect if a script contains the\r\n MAGIC LINE:\r\n from __future__ import pseudomethod\r\n 2 the script is preparsed, replacing the \"..\" notation w/ \".__pseudomethod__.\"\r\n to keep the python parser happy\r\n 3 the script is compiled into an ast object. the ast is recursively searched\r\n for the attribute \"__pseudomethod__\" where some symbol rearrangement occurs.\r\n\r\nRECENT CHANGEs:\r\n20081219\r\n- tobias rodaebel points out \"..\" is used in relative imports as well.\r\n fixed pseudomethod 2 b compatible w/ this\r\n- removed limitation where parser disallows use of keyword \"__pseudomethod__\"\r\n in scripts\r\n20081121 created pseudomethod package", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/pseudomethod", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "pseudomethod", "package_url": "https://pypi.org/project/pseudomethod/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pseudomethod/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/pseudomethod" }, "release_url": "https://pypi.org/project/pseudomethod/2008.12.20/", "requires_dist": null, "requires_python": null, "summary": "call almost any function on-the-fly as a method", "version": "2008.12.20" }, "last_serial": 144945, "releases": { "2008.11.21": [ { "comment_text": "", "digests": { "md5": "4bb5cfdfe16b8d2da7e996fbf1b43f19", "sha256": "ad7b32cea3cbd9c8857b44700d46ee55bece255b024ad8dc7cdfde153b2e7475" }, "downloads": -1, "filename": "pseudomethod-2008.11.21.tar.gz", "has_sig": false, "md5_digest": "4bb5cfdfe16b8d2da7e996fbf1b43f19", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6448, "upload_time": "2008-11-22T14:30:51", "url": "https://files.pythonhosted.org/packages/46/59/233805eb81abff2552851bd3ad1f5900b0dc7a31aac36164622c69fd5722/pseudomethod-2008.11.21.tar.gz" } ], "2008.11.22": [ { "comment_text": "", "digests": { "md5": "e81b7d4ed1c899e3fc6c7ed95977128a", "sha256": "025469af9aea0d58a5c46dc1fd5e743e52c2eafe2fa166bab0bdc7d8251cbada" }, "downloads": -1, "filename": "pseudomethod-2008.11.22.tar.gz", "has_sig": false, "md5_digest": "e81b7d4ed1c899e3fc6c7ed95977128a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6519, "upload_time": "2008-11-23T16:29:46", "url": "https://files.pythonhosted.org/packages/3c/b5/8a804dc38ed435f4a41be848d84e8bdd07c13e9aef72c2db7496e6f3346b/pseudomethod-2008.11.22.tar.gz" } ], "2008.12.19": [ { "comment_text": "", "digests": { "md5": "c7ec0b70e75905c4b000ada56187c8a8", "sha256": "352d2180fd841585357b54fcda567f03104680d818f289c030181bac2808f335" }, "downloads": -1, "filename": "pseudomethod-2008.12.19.tar.gz", "has_sig": false, "md5_digest": "c7ec0b70e75905c4b000ada56187c8a8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7061, "upload_time": "2008-12-21T22:41:42", "url": "https://files.pythonhosted.org/packages/bb/1c/bdae1847fe5f9760c702542fe88b433575de1f53c9f17b1c411d5b4fea1f/pseudomethod-2008.12.19.tar.gz" } ], "2008.12.20": [ { "comment_text": "", "digests": { "md5": "7e564c52ab89d9eb3de89f00f18b8204", "sha256": "e1f71c706b2d96dea14e8ad02100aac23ddf1e5c3bd49dc93e1d2468634997b5" }, "downloads": -1, "filename": "pseudomethod-2008.12.20.tar.gz", "has_sig": false, "md5_digest": "7e564c52ab89d9eb3de89f00f18b8204", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6927, "upload_time": "2009-01-04T10:20:18", "url": "https://files.pythonhosted.org/packages/d7/8e/04edc85ef49789a895ac0eb11cae5962f15ebaf3f654d4905bb0314d600b/pseudomethod-2008.12.20.tar.gz" } ], "2009.11.16.py3k.cpp": [ { "comment_text": "", "digests": { "md5": "4173df5d0d37130dc9365710c803bf30", "sha256": "92b8312830ab8f4319df091c12e3ecf4aced765166f1dfec3da500c5f5b887fa" }, "downloads": -1, "filename": "pseudomethod-2009.11.16.py3k.cpp.tar.gz", "has_sig": false, "md5_digest": "4173df5d0d37130dc9365710c803bf30", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 85418, "upload_time": "2009-11-19T04:33:51", "url": "https://files.pythonhosted.org/packages/88/90/7c7c779da7f17b54aaba445ce65003a9f790d3dabb9e8467207f3a30e369/pseudomethod-2009.11.16.py3k.cpp.tar.gz" } ], "2009.12.30.py3k.cpp": [ { "comment_text": "", "digests": { "md5": "ec9caa79cc553ed6bc0758988212b006", "sha256": "1a255343ea1dde0e7ea7b5009cc6680fc5c1919dbcf1b922ab29f7fb18798bc6" }, "downloads": -1, "filename": "pseudomethod-2009.12.30.py3k.cpp.tar.gz", "has_sig": false, "md5_digest": "ec9caa79cc553ed6bc0758988212b006", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 89136, "upload_time": "2010-01-01T23:54:06", "url": "https://files.pythonhosted.org/packages/31/65/fb19b818f037b547578409073b32b04fd16950661739008a0703c6b5109d/pseudomethod-2009.12.30.py3k.cpp.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7e564c52ab89d9eb3de89f00f18b8204", "sha256": "e1f71c706b2d96dea14e8ad02100aac23ddf1e5c3bd49dc93e1d2468634997b5" }, "downloads": -1, "filename": "pseudomethod-2008.12.20.tar.gz", "has_sig": false, "md5_digest": "7e564c52ab89d9eb3de89f00f18b8204", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6927, "upload_time": "2009-01-04T10:20:18", "url": "https://files.pythonhosted.org/packages/d7/8e/04edc85ef49789a895ac0eb11cae5962f15ebaf3f654d4905bb0314d600b/pseudomethod-2008.12.20.tar.gz" } ] }