{ "info": { "author": "kai zhu", "author_email": "kaizhu256@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: End Users/Desktop", "Intended Audience :: Science/Research", "License :: OSI Approved :: GNU General Public License (GPL)", "Natural Language :: English", "Operating System :: POSIX", "Operating System :: POSIX :: Linux", "Programming Language :: C", "Programming Language :: C++", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.1", "Topic :: Multimedia", "Topic :: Multimedia :: Graphics", "Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering :: Mathematics", "Topic :: Scientific/Engineering :: Visualization", "Topic :: Software Development", "Topic :: Software Development :: Code Generators", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "DESCRIPTION: pseudosugar - extend python with functional programming language features\n\n REQUIRES: LINUX OS AND PYTHON3.1\n\n QUICK TEST: $ python3.1 setup.py build dev --quicktest\n\n SUMMARY:\n pseudosugar is a pure python module.\n pseudosugar is a python ast tree hack, adding the following syntax sugars:\n\n function<<<< aa, bb, cc, ... -> function(aa, bb, cc, ...)\n aa, bb, cc, ... >>>>function -> function(aa, bb, cc, ...)\n\n xx ..function(aa, bb, cc) -> function(xx, aa, bb, cc)\n xx ...function(aa, bb, cc) -> function(aa, xx, bb, cc)\n xx ....function(aa, bb, cc) -> function(aa, bb, xx, cc)\n \nRECENT CHANGELOG:\n 20091231 - added <<<< and >>>> sugar\n 20091224 - added pseudomethod interactive console - revamped pseudomethod import hook\n 20091224 - modularized package - fix install issues - added sdist check\n 20091209 - improved documentation\n 20091205 - moved source code to c++\n 20091116 - package integrated\n\nDEMO USAGE:\n\n>>> ## start up the interactive console\n>>> from pseudosugar import *\n>>> pseudo_console().interact()\n\nPython 3.1.1 (r311:74480, Sep 13 2009, 17:17:12)\n[GCC 4.3.2] on linux2\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n(pseudo_console)\npseudo_importer - adding hook to sys.meta_path\n>>> from pseudosugar import *\n\n>>> #### QUICK EXAMPLES\n>>> ## prefix operator\n>>> print<<<< 'hello', 'world'\nhello world\n\n>>> ## postfix operator\n>>> 'hello', 'world' >>>>print\nhello world\n\n>>> ## pseudomethod\n>>> def function(aa, bb, cc): return (aa, bb, cc)\n>>> 1 ..function(0, 0) >>>>print\n(1, 0, 0)\n>>> 2 ...function(0, 0) >>>>print\n(0, 2, 0)\n>>> 3 ....function(0, 0) >>>>print\n(0, 0, 3)\n\n\n\n\n\n\n\n>>> ## '<<<<' CONVERTS FUNCTIONS INTO PREFIX OPERATORS\n>>> ## foo<<<< turns foo into a prefix operator\n>>> ## foo<<<< will take in everything to its right that is comma delimited\n>>> ## print<<<< is useful for making print statements\n>>> print<<<< 'bob says', 'hello ' + re.sub<<<< re.compile('(\\w+)'), '\\\\1!', 'world'\nbob says hello world!\n\n>>> ## '>>>>' CONVERTS FUNCTIONS INTO POSTFIX OPERATORS\n>>> ## it behaves almost exactly like '>>>>' except in reverse\n>>> ## it is useful for chaining together multiple operators\n>>> 'qwerty' >>>>list >>>>sorted >>>>enumerate >>>>dict >>>>print\n{0: 'e', 1: 'q', 2: 'r', 3: 't', 4: 'w', 5: 'y'}\n\n>>> ## OPERATOR PRECEDENCE\n>>> ## '>>>>' has higher operator precedence than '<<<<'\n>>> print( list<<<< 'abcd' >>>>tuple ) ## list(tuple('abcd'))\n['a', 'b', 'c', 'd']\n\n\n\n\n\n\n\n>>> #### PSEUDOMETHOD SYNTAX\n>>> ## DYNAMICALLY BIND FUNCTION CALLS TO OBJECTS\n>>> ## bind the function call print() to 'hello'\n>>> print('hello')\nhello\n>>> 'hello' ..print()\nhello\n>>> 'hello' ..print('world')\nhello world\n>>> 'hello' ..print('world', '!')\nhello world !\n>>> 'hello' ..print('world', '!', file = sys.stdout)\nhello world !\n\n>>> ## create a string pseudomethod which adds an exclamation or other endings\n>>> def add_ending(self, end = '!'): return self + end\n>>> 'hello' ..add_ending() ..print()\nhello!\n>>> 'hello'.upper() ..add_ending() ..print()\nHELLO!\n>>> 'hello'.upper() ..add_ending(' world') ..print()\nHELLO world\n>>> 'hello'.upper() ..add_ending(' world').lower() ..print()\nhello world\n>>> 'hello'.upper() ..add_ending(' world').lower() ..add_ending('!') ..print()\nhello world!\n>>> 'hello'.upper() ..add_ending(' world').lower() ..add_ending('!') ..add_ending(end = '!') ..print()\nhello world!!\n\n\n\n>>> ## OPERATOR PRECEDENCE\n>>> ## 'aa ..bb()' has the same operator precedence as the attribute operator 'a.b'\n>>> def add(aa, bb): return aa + bb\n>>> print( 2 * 3 ..add(4) + 5 == 2 * (3 + 4) + 5 )\nTrue\n>>> print( 3 == 1 ..add(2) )\nTrue\n>>> print( 0, 0 ..add(1), 0 )\n0 1 0\n\n\n\n>>> ## EXTEND RESTRICTED TYPES\n>>> ## the python code object type cannot be subtyped nor will it accept any method binding.\n>>> ## however, we can extend it by dynamically binding ordinary functions.\n>>> ## here's a pseudomethod which disassembles an instance of the type to a specified output\n>>> import dis, io, sys\n>>> def disassemble(self, file):\n... backup_stdout = sys.stdout ## backup sys.stdout\n... try:\n... sys.stdout = file\n... dis.dis(self) ## disassemble self\n... return file\n... finally:\n... sys.stdout = backup_stdout ## restore sys.stdout\n\n>>> code_source = 'print( \"hello\" )'; code_object = compile(code_source, '', 'exec'); exec( code_object )\nhello\n>>> code_object ..disassemble(file = io.StringIO()).getvalue() ..print()\n 1 0 LOAD_NAME 0 (print) \n 3 LOAD_CONST 0 ('hello') \n 6 CALL_FUNCTION 1 \n 9 POP_TOP \n 10 LOAD_CONST 1 (None) \n 13 RETURN_VALUE \n\n\n\n\n>>> ## '...' AND '....' SYNTAX\n>>> ## sometimes we instead want the 2nd or 3rd argument of a function bound to an object.\n>>> ## '...' and '....' will do this respectively\n>>> '2nd' ...print(0, 0)\n0 2nd 0\n>>> '3rd' ....print(0, 0)\n0 0 3rd\n\n>>> ## '....' is useful for chaining re.sub\n>>> ss = 'file = io.StringIO(); print 1, 2, 3 >> file; print file.getvalue()'; print( ss )\nfile = io.StringIO(); print 1, 2, 3 >> file; print file.getvalue()\n\n>>> print(\n... re.sub('print (.*?)$', 'print( \\\\1 )',\n... re.sub('print (.*) >> (.*?);', 'print( \\\\1, file = \\\\2 );', ss)\n... )\n... )\nfile = io.StringIO(); print( 1, 2, 3, file = file ); print( file.getvalue() )\n\n>>> ss ....re.sub('print (.*) >> (.*?);', 'print( \\\\1, file = \\\\2 );') \\\n... ....re.sub('print (.*?)$', 'print( \\\\1 )') \\\n... ..print()\nfile = io.StringIO(); print( 1, 2, 3, file = file ); print( file.getvalue() )\n\n>>> ## in fact, another primary use of pseudomethod is to flatten ugly, hard-to-read, lisp-like nested function calls\n>>> print( dict( enumerate( zip( 'abc', sorted( 'abc bca cab'.split(' '), key = lambda x: x[1] ) ) ) ) )\n{0: ('a', 'cab'), 1: ('b', 'abc'), 2: ('c', 'bca')}\n\n>>> 'abc bca cab'.split(' ') ..sorted(key = lambda x: x[1]) ...zip('abc') ..enumerate() ..dict() ..print()\n{0: ('a', 'cab'), 1: ('b', 'abc'), 2: ('c', 'bca')}\n\n\n\n>>> ## IMPORT MODULES WRITTEN WITH PSEUDOMETHOD SYNTAX\n>>> ## create test_module.py\n>>> open('test_module.py', 'w').write('\"hello\" ..print()\\n') ..print('bytes written')\n18 bytes written\n\n>>> ## during import, insert the magic prefix 'pseudosugar.' before the last module\n>>> ## import pseudosugar.a\n>>> ## import a.pseudosugar.b\n>>> ## import a.b.pseudosugar.c\n>>> import pseudosugar.test_module\nhello", "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/pseudosugar", "keywords": null, "license": "gpl", "maintainer": null, "maintainer_email": null, "name": "pseudosugar", "package_url": "https://pypi.org/project/pseudosugar/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pseudosugar/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/pseudosugar" }, "release_url": "https://pypi.org/project/pseudosugar/2010.01.01.README/", "requires_dist": null, "requires_python": null, "summary": "DESCRIPTION: pseudosugar - extend python with functional programming language features", "version": "2010.01.01.README" }, "last_serial": 796756, "releases": { "2010.01.01.README": [ { "comment_text": "", "digests": { "md5": "07832f7642f640fdb423eb2886196d7d", "sha256": "736e1bfe5fef9e81c368eb32d668c2e4599ce230ca398793561788e505526456" }, "downloads": -1, "filename": "pseudosugar-2010.01.01.README.tar.gz", "has_sig": false, "md5_digest": "07832f7642f640fdb423eb2886196d7d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 90063, "upload_time": "2010-01-04T20:15:21", "url": "https://files.pythonhosted.org/packages/0f/91/bfbbd5ff836e03472387e89320a14940908f795d73d098312b33f1b8046f/pseudosugar-2010.01.01.README.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "07832f7642f640fdb423eb2886196d7d", "sha256": "736e1bfe5fef9e81c368eb32d668c2e4599ce230ca398793561788e505526456" }, "downloads": -1, "filename": "pseudosugar-2010.01.01.README.tar.gz", "has_sig": false, "md5_digest": "07832f7642f640fdb423eb2886196d7d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 90063, "upload_time": "2010-01-04T20:15:21", "url": "https://files.pythonhosted.org/packages/0f/91/bfbbd5ff836e03472387e89320a14940908f795d73d098312b33f1b8046f/pseudosugar-2010.01.01.README.tar.gz" } ] }