{ "info": { "author": "Beomsoo Kim", "author_email": "bluewhale8202@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3" ], "description": "# What is pythonp?\n\n**pythonp** is a simple utility script that helps you using python on the\ncommand line. Basically, it's a **python -c** command with a handy print\nfunction **p**. See examples below to see how convenient it can be. \nBy design, it avoids adding much sugar to the goold old\n**python -c**. It introduces no magic except\nfor a few preprocessings and handy global variables.\nThe goal of this project is to deliver seamless experience to\npython users and become a part of some major python\nimplementations in the end, without remaining as a standalone package.\n\n\n# Disclaimer\n\nThere are already several projects that have\nsmilar goals with this project such as\n[pyp](https://code.google.com/archive/p/pyp/),\n[pythonpy](https://github.com/Russell91/pythonpy) and others.\nParticularly [pythonpy](https://github.com/Russell91/pythonpy) is super\npopular. I think they are all amazing projects and I don't mean to assert that\nevery aspect of **pythonp** is breakingly new. \nBut there are fundamental differences between **pythonp**\nand others. Notably, **pythonp** has been designed\nto be able to run *any python programs*, not just\nsingle statements. Any\nvalid python code should be able to be run with **pythonp** and only\n(almost valid) python code should.\n\n\n## How to install\n\nYou can install it via pip\n```bash\npython -m pip install pythonp\n```\n\nor you can simply download this repository and copy `__main__.py` to\none of your `$PATH` locations\n```bash\ncp pythonp/__main__.py ...../pythonp\n```\n\n\n## Handy global variables defined\n\n#### `p`\nA handy print function with commandline usage in mind. It has the\nsimilar interface to the built-in `print` with some exceptions.\n- It specially handles a single iterable as an argument,\nin which case it prints as many\ntimes as the number of elements in the iterable. Giving extra positional\narguments along with an iterable is not allowed.\n\n#### `lines`\nStandard input lines. You can think of it as `sys.stdin` except that\neach line of it doesn't end with a newline character. Also note that it's\nsubscriptable and allows a one-time random access, which means you\ncan do something like `lines[3], lines[10:]`.\n\n#### `l`\n`l` is a line from the standard input. It also doesn't end with a new\nline character.\nWithout `-e` option, `l` is the first line from the standard input.\nWith `-e` option, it represents each line\nof the standard input. See the feature explanation below to learn `-e` option.\n\n#### `_lines`\nLazy evaluted non-stream-like version of `lines`.\nBecuase it's a `collections.abc.Sequence`, you can access its \nlines multiple times, reverse it, do inclusion test on it,\nand so forth. The lines are not prepared until you actually\nuse it to save up memory.\n\n\n## Features\n* The last expression is automatically printed with `p` function if your\ncode dind't write anything to `sys.stdout` and the last expression does\nnot evalute to `None`. If you don't want this feature you can put\nsomething like `;pass` or `;None` in the end of your code.\n\n* If `-e` option is given, your code is applied to each line `l` of the\nstanard input, not the\nentire lines `lines` or `_lines`. The names `lines` and `_lines` will\ndisappear and can not be used. Note that in the current implementation,\nglobals are shared during continued executions of the code\n and there could be some side effects.\nThis is an intended behavior but can change in the future.\n\n\n* Automatic importing is supported. `pythonp` automatically tries to\nimport a name for you when it encounters an unseen one.\n\n* Backtick(\\`) in code is replaced with `\"\"\"` so that you can have\none more way to make string literals. In python 3.6 or above `f` prefix\nis also added to make the enclosed section a **f-string**.\nFor example, you can do\nsomething like this.\n```bash\n$ echo 91/seoul/bombs | pythonp \"`name='{l.split('/')[2]}'`\" # python3.6+\nname='bombs'\n```\n\n\n## Examples\n\nMake commands that you want on the fly and and run them with your shell\n```bash\n# Remove extensions of .txt files\n$ ls | pythonp -e \"if l.endswith('.txt'): p('mv', l, l[:-4])\" | sh\n```\n\nRandomly sample N lines from a large number of lines\n``` bash\n# choose n files randomly\nls | pythonp \"random.sample(_lines, 3)\"\nitem_1443\nitem_6360\nitem_7285\n```\n\nConcatenate lines\n```bash\n$ ls | pythonp \"','.join(l.strip() for l in lines if not 'bombs' in l)\"\nLICENSE,README.md,pythonp,setup.py\n```\n\nDo something for **e**ach line\n```bash\n# A web crawler one-liner\n$ cat urls.txt | pythonp -e 'p(requests.get(l)); time.sleep(1)' > output\n```\n\nSplit a long line and output the nth chunk \n```bash\n# Get the 4th column from the current processs status \n$ ps | tail -n+1 | pythonp -e \"l.split()[3]\"\n/usr/local/bin/fish\n-fish\npython3\nssh\n\n# Only using only pythonp\n$ ps | pythonp \"lines[1:]\" | pythonp -e \"l.split()[3]\"\n```\n\nOthers\n```bash\n# Use it to solve some weird quiz\n$ pythonp \"now=datetime.datetime.now();(now.year+now.day)%10\"\n\n# Make at most 5 random names\n$ pythonp \"'\\n'*(5-1)\" | pythonp -e \"''.join(random.sample(string.ascii_letters, 7))\" | xargs touch\n```\n\n\n## Misc\n\n* If you want a shorter name for `pythonp` you can do something like this. \n```bash\nmv $(which pythonp) $(dirname $(which pythonp))/py # rename pythonp to py\n```\n\n* Both python2 and python3 are supported.\n\n* Refer to python official docs to learn useful string manipulating functions\nhttps://docs.python.org/3/library/string.html\n\n* It is a good idea to use generator expressions or list comprehensions\nwith pythonp\nhttps://docs.python.org/3/howto/functional.html\n\n* If you want some other features, you are always welcome to make an issue\nat the issue tab on the top menu.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bombs-kim/pythonp", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pythonp", "package_url": "https://pypi.org/project/pythonp/", "platform": "", "project_url": "https://pypi.org/project/pythonp/", "project_urls": { "Homepage": "https://github.com/bombs-kim/pythonp" }, "release_url": "https://pypi.org/project/pythonp/0.3.6/", "requires_dist": null, "requires_python": "", "summary": "A powerful utility that empowers pythonistas in the command line", "version": "0.3.6" }, "last_serial": 4686448, "releases": { "0.0.0": [ { "comment_text": "", "digests": { "md5": "21115d118d905363561caba5d97653b1", "sha256": "a7078af021d59f2b7998eacb878c35022937bb4c6425b160a41bd2648aa11d17" }, "downloads": -1, "filename": "pythonp-0.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "21115d118d905363561caba5d97653b1", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5454, "upload_time": "2018-12-31T07:40:42", "url": "https://files.pythonhosted.org/packages/7f/fd/1677b8848bb764e9f822a85daabbaab72c297c5b301de76949fafc5ba0d2/pythonp-0.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "06675323c026a0bc9347fe9071d073b3", "sha256": "41d6a4c97474212b22addc16107680b58ff610473696c5be87fb1fb8e2c187f6" }, "downloads": -1, "filename": "pythonp-0.0.0-py3.6.egg", "has_sig": false, "md5_digest": "06675323c026a0bc9347fe9071d073b3", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 6586, "upload_time": "2019-01-01T17:09:38", "url": "https://files.pythonhosted.org/packages/fd/4d/f723886686b8fa7a3232d11757accd77e1b13149c9a6d6ed31165fc08f96/pythonp-0.0.0-py3.6.egg" }, { "comment_text": "", "digests": { "md5": "2cc822df1859b5c13242fea2e58ff07d", "sha256": "c2a8a9659321c32fbb151fc3e9ce86e669680c3b0c7a1a6229c559361a3fe4c2" }, "downloads": -1, "filename": "pythonp-0.0.0.tar.gz", "has_sig": false, "md5_digest": "2cc822df1859b5c13242fea2e58ff07d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3781, "upload_time": "2018-12-31T07:40:44", "url": "https://files.pythonhosted.org/packages/4c/b9/766264fe17e65772b60eb4127e418cd66dc0c399a2b22d392d6bb1c7fcc2/pythonp-0.0.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "57549b45f0524c0f6c327b02ad496846", "sha256": "f2166f163d4c4b8b61170605d758da92765cdd35a3917ef7c54c504378e43063" }, "downloads": -1, "filename": "pythonp-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "57549b45f0524c0f6c327b02ad496846", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5625, "upload_time": "2019-01-03T14:59:51", "url": "https://files.pythonhosted.org/packages/7f/b9/05fae1b1ddc55ac93289b9fb5bd238a7c0180edfa3cc430ef86f4e81623f/pythonp-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9c7e191d6f9495c026137490759a015a", "sha256": "fcbab2c56e0a75f778fec13b69b850e66fef7edbd4246c226d4894ede4e69e29" }, "downloads": -1, "filename": "pythonp-0.2.1.tar.gz", "has_sig": false, "md5_digest": "9c7e191d6f9495c026137490759a015a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5387, "upload_time": "2019-01-03T14:59:53", "url": "https://files.pythonhosted.org/packages/05/ce/562a93888fd143a584ffca9b33ef0c5fc77b8b48b7186094a2cf92bddff4/pythonp-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "fbbd3b830a887e0f8d7a1c540c148633", "sha256": "93cc53f047617f07415ca75f9ab55e1b3866a0eb5317a14ad3a344982519cd1b" }, "downloads": -1, "filename": "pythonp-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fbbd3b830a887e0f8d7a1c540c148633", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5893, "upload_time": "2019-01-03T16:17:55", "url": "https://files.pythonhosted.org/packages/fa/b4/7b03b9b7bb8315747c6462397b8cabac6f57615631df63b43235b3d52033/pythonp-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ea83590ed239b830977b4ca9628f191a", "sha256": "69a0b71b9afe29fb1c0a64758c2b752d2a2c0972f3864018b2d9a456cad6f8c9" }, "downloads": -1, "filename": "pythonp-0.3.0-py3.6.egg", "has_sig": false, "md5_digest": "ea83590ed239b830977b4ca9628f191a", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 9022, "upload_time": "2019-01-03T16:17:57", "url": "https://files.pythonhosted.org/packages/02/e3/e7374aa1acbb7f42b4d9c5666f2b1cb234a0c9d75431afe53e1f7a7649a0/pythonp-0.3.0-py3.6.egg" }, { "comment_text": "", "digests": { "md5": "d3975d35e844004830ae74e0e14c445e", "sha256": "96b0388d5a23810d72e565f0044e14c73499f28fa863c1689812ebf8a0d15d36" }, "downloads": -1, "filename": "pythonp-0.3.0.tar.gz", "has_sig": false, "md5_digest": "d3975d35e844004830ae74e0e14c445e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5699, "upload_time": "2019-01-03T16:17:58", "url": "https://files.pythonhosted.org/packages/04/f4/dfe1751d330c41f87bfe35871800cf6495f0f88070c6e064f2bbd13ea179/pythonp-0.3.0.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "21da4a4156fdc9d262429cfceb4a857a", "sha256": "0d00fdc25599aa520636930752edb6047972da515a41cf97bb8874df20103f01" }, "downloads": -1, "filename": "pythonp-0.3.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "21da4a4156fdc9d262429cfceb4a857a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6119, "upload_time": "2019-01-05T03:39:12", "url": "https://files.pythonhosted.org/packages/aa/dc/e156a7bed513474ba79085a37da1edbd98db7d51797517ff4a2ceb9fb443/pythonp-0.3.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c76cbf93490981ed76d5efdbd745b579", "sha256": "f3fbb8d01dc03bd1271d18320e442d61b5cf8ee2d8d3bebb1c7635c8ad4af8ce" }, "downloads": -1, "filename": "pythonp-0.3.2.tar.gz", "has_sig": false, "md5_digest": "c76cbf93490981ed76d5efdbd745b579", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5904, "upload_time": "2019-01-05T03:39:14", "url": "https://files.pythonhosted.org/packages/d9/fe/b8b074c6f65faa816ab59a729a5187032ac96d2564556ff276fbb8dd8a9d/pythonp-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "c10937ae3860e55d9519648fb3479adc", "sha256": "59fda489949997f49f245e9c6aea74b864d6f6e1f77afd6ef0a005ccccd91c3d" }, "downloads": -1, "filename": "pythonp-0.3.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c10937ae3860e55d9519648fb3479adc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6645, "upload_time": "2019-01-05T17:22:56", "url": "https://files.pythonhosted.org/packages/58/9b/8f5ae194c581e9084283ac51f958e2fc120db77f0fa7b69c50a6e036b2fc/pythonp-0.3.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0379c49ed5413c8270500fd906f19e3c", "sha256": "9367646be0d788ccd9f542e9708ca7d0d6408bbd7448d9be08d5a9ca9fd09eb2" }, "downloads": -1, "filename": "pythonp-0.3.3.tar.gz", "has_sig": false, "md5_digest": "0379c49ed5413c8270500fd906f19e3c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6457, "upload_time": "2019-01-05T17:22:57", "url": "https://files.pythonhosted.org/packages/da/2b/9f7cfd9315515ba3306579116606fea5fd33154b5eeeea2ba66a4b1279a0/pythonp-0.3.3.tar.gz" } ], "0.3.4": [ { "comment_text": "", "digests": { "md5": "016b5ea96bb6468a50e1c0f757bc0951", "sha256": "2c546d12bb797c3a638f3fb4c5726aad38402cb649ff7ac5ec7099405a37ad11" }, "downloads": -1, "filename": "pythonp-0.3.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "016b5ea96bb6468a50e1c0f757bc0951", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6815, "upload_time": "2019-01-05T18:39:17", "url": "https://files.pythonhosted.org/packages/9e/2a/650fc9758b184fee9b8256f596ef4c540ca225b4419086e3de87d28ab81e/pythonp-0.3.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f49dd27e3b2a9a46341cc2da19d6967b", "sha256": "4de490f10c63fb6b85fbc13616b72acededd3c22baf106a0ec2fc8200ac918e8" }, "downloads": -1, "filename": "pythonp-0.3.4.tar.gz", "has_sig": false, "md5_digest": "f49dd27e3b2a9a46341cc2da19d6967b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6644, "upload_time": "2019-01-05T18:39:19", "url": "https://files.pythonhosted.org/packages/74/c4/ba9a1af529f6f7b167e9a0642274a2169cc0666ec8c8f1df24d9ddc1d4be/pythonp-0.3.4.tar.gz" } ], "0.3.5": [ { "comment_text": "", "digests": { "md5": "cadf82da55644f0e3b82707ba26fc035", "sha256": "cb11b5bbc0b9d29cc0437234967e6c1a47d91f44bd834025beba8958f8522379" }, "downloads": -1, "filename": "pythonp-0.3.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "cadf82da55644f0e3b82707ba26fc035", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6849, "upload_time": "2019-01-05T19:44:58", "url": "https://files.pythonhosted.org/packages/43/9b/1b3363bd1cb98081941c581ca95de80d25cf3afafe4e900577a9c19c172e/pythonp-0.3.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "82f985892448d89ef11cf1e248b355d5", "sha256": "5a6b44735b06378a1a1639b0c9839169ebc3b04d6d223d5a2fedde73ae28aab6" }, "downloads": -1, "filename": "pythonp-0.3.5.tar.gz", "has_sig": false, "md5_digest": "82f985892448d89ef11cf1e248b355d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6681, "upload_time": "2019-01-05T19:45:00", "url": "https://files.pythonhosted.org/packages/bd/da/fbea1e77b9a0cd829bf3ca53fe90d8bd0e4ea5801bbee25e23aa3972432f/pythonp-0.3.5.tar.gz" } ], "0.3.6": [ { "comment_text": "", "digests": { "md5": "0c582dbd3ddd469dea9ce41d27930db9", "sha256": "683641cde442634c1b0085545641fa8dc292b44448cd7085e0cb2c98de48c5a3" }, "downloads": -1, "filename": "pythonp-0.3.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0c582dbd3ddd469dea9ce41d27930db9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7238, "upload_time": "2019-01-11T17:45:56", "url": "https://files.pythonhosted.org/packages/90/04/f0015b67e6d52d4a28f6468796bce42e3ac7f51d42b0bd03c17520116590/pythonp-0.3.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0ba7d2090f52604f838f254b7bca9647", "sha256": "93871f9d5899896f2b42fed40f424ecc9b0420c4cb8777fd4bb2dda03dc5798a" }, "downloads": -1, "filename": "pythonp-0.3.6.tar.gz", "has_sig": false, "md5_digest": "0ba7d2090f52604f838f254b7bca9647", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7128, "upload_time": "2019-01-11T17:45:58", "url": "https://files.pythonhosted.org/packages/2d/78/0a339f403f63acd5eda74f277bb2adbb0eaf654b76932c37d68c8aacbbfc/pythonp-0.3.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0c582dbd3ddd469dea9ce41d27930db9", "sha256": "683641cde442634c1b0085545641fa8dc292b44448cd7085e0cb2c98de48c5a3" }, "downloads": -1, "filename": "pythonp-0.3.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0c582dbd3ddd469dea9ce41d27930db9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7238, "upload_time": "2019-01-11T17:45:56", "url": "https://files.pythonhosted.org/packages/90/04/f0015b67e6d52d4a28f6468796bce42e3ac7f51d42b0bd03c17520116590/pythonp-0.3.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0ba7d2090f52604f838f254b7bca9647", "sha256": "93871f9d5899896f2b42fed40f424ecc9b0420c4cb8777fd4bb2dda03dc5798a" }, "downloads": -1, "filename": "pythonp-0.3.6.tar.gz", "has_sig": false, "md5_digest": "0ba7d2090f52604f838f254b7bca9647", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7128, "upload_time": "2019-01-11T17:45:58", "url": "https://files.pythonhosted.org/packages/2d/78/0a339f403f63acd5eda74f277bb2adbb0eaf654b76932c37d68c8aacbbfc/pythonp-0.3.6.tar.gz" } ] }