{"id":16390068,"url":"https://github.com/r2dev2/pypthon","last_synced_at":"2025-10-26T13:30:50.254Z","repository":{"id":62582751,"uuid":"319155218","full_name":"r2dev2/Pypthon","owner":"r2dev2","description":"A python commandline tool using bash-like pipes.","archived":false,"fork":false,"pushed_at":"2021-01-06T01:49:21.000Z","size":210,"stargazers_count":10,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-07T15:35:54.138Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r2dev2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-06T23:38:52.000Z","updated_at":"2023-03-30T00:23:47.000Z","dependencies_parsed_at":"2022-11-03T21:57:29.441Z","dependency_job_id":null,"html_url":"https://github.com/r2dev2/Pypthon","commit_stats":null,"previous_names":["r2dev2bb8/pypthon"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r2dev2%2FPypthon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r2dev2%2FPypthon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r2dev2%2FPypthon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r2dev2%2FPypthon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r2dev2","download_url":"https://codeload.github.com/r2dev2/Pypthon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219862888,"owners_count":16555951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T04:34:53.275Z","updated_at":"2025-10-26T13:30:44.984Z","avatar_url":"https://github.com/r2dev2.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pypthon\n\nPipes for python3 to be used in shell\n\n![cfilter demo](https://raw.githubusercontent.com/r2dev2bb8/Pypthon/master/img/maindemo.png)\n\n# Setup\n\n```\npip install pypthon -U \n```\n\n# Usage\n\n```\npyp 'Pypthon command'\n```\n\nIf pypthon is not in your path, you must invoke via\n\n```\npython3 -m pypthon 'Pypthon command\n```\n\nTo see the python code being generated, use the ``--show-python`` flag:\n\n```\npyp --show-python 'Python command'\n```\n\nA Pypthon command consists of the following\n\n```\nsource | piped function | piped function | piped function\n```\n\nThe source must be any python expression. To have the source be an external command being piped into Pypthon, use ``stdin``.\n\n## Piped functions\n\nPiped functions are any python functions which take the previous value as their last argument. In the example pypthon code,\n\n```python\n[2, 1, 3] | sorted | print \"Sorted\" \"list:\"\n```\n\n``sorted`` takes in the iterable ``[2, 1, 3]`` as its last parameter and ``print`` takes the sorted list as its last parameter. When passing other arguments to functions in Pypthon, one must use the space separated syntax. In our example, the strings ``\"Sorted\"`` and ``\"list:\"`` are passed as arguments to ``print`` via the syntax of separating each argument with a space.\n\n```\nSorted list: [1, 2, 3]\n```\n\nwill be outputted by the above command.\n\n## Lambda expressions\n\nIn python, lambdas are of the following structure\n\n```python\nlambda arg1, arg2: arg1 + arg2\n```\n\nIn pypthon, lambda expressions do not need the ``lambda`` keyword before the arguments. In the example,\n\n```python\n['1.', '6.', '2.', '4.'] | map x: int(float(x)) | reduce x, y: x if x \u003e y else y | print\n```\n\n``map`` converts the strings in the list into integers, and ``reduce`` finds the maximum of the integers.\n\n## Environment\n\nThe environment is fully customizable with a ``.pypthonrc.py``. On startup, the pypthonrc will be imported, giving the pypthon command access to custom functions. If you feel like you have general functions that can be used by other pypthon users, do not hesitate to send a pull request to add your customizations to the standard environment as it is still growing. It is advisable to not include heavy imports such as ``numpy`` to the pypthonrc as the startup time will be negatively impacted for each invocation of pypthon.\n\nTo import modules specifically for the Pypthon invocation, use the ``-i`` flag.\n\n```\npyp -i 'requests' -i 'numpy as np' \"[1, 2, 3] | map x: requests.get('https://google.com').status_code | list | np.mean | print\"\n```\n\nIn the above example, numpy and requests were imported. The syntax of ``module`` ``as`` ``alias`` is valid in Pypthon. The methods in the modules are available for use in Pypthon.\n\nThe documentation for the standard environment is at [docs/example.md](https://github.com/r2dev2bb8/Pypthon/blob/master/docs/environment.md).\n\n# Other\n\nThere are currently some bugs in parsing the source to the pipe chain. If it incorrectly raises an error in the first pipe segment, surround it with parenthesis and see if it works.\n\nThis project idea was heavily inspired by the pied piper package which only works with Python 2 and has virtually disappeared.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr2dev2%2Fpypthon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr2dev2%2Fpypthon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr2dev2%2Fpypthon/lists"}