No project description provided
Project description
Pypthon
Pipes for python3 to be used in shell
Setup
pip install -U pypthon
Usage
pyp 'Pypthon command'
A Pypthon command consists of the following
source | piped function | piped function | piped function
The source must be any python expression. To have the source be another command being piped into Pypthon, use stdin
.
Piped functions
Piped functions are any python functions which take the previous value as their last argument. In the example,
[2, 1, 3] | sorted | print "Sorted" "list:"
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.
Sorted list: [1, 2, 3]
will be outputted by the above command.
Lambda expressions
In python, lambdas are of the following structure
lambda arg1, arg2: arg1 + arg2
In pypthon, lambda expressions do not need the lambda
keyword before the arguments. In the example,
['1.', '6.', '2.', '4.'] | map x: int(float(x)) | reduce x, y: x if x > y else y | print
map
converts the strings in the list into integers, and reduce
finds the maximum of the integers.
Environment
# TODO documentation, for now just look in pypthon/environment.py
Other
This project idea was heavily inspired by the pied piper package which only works with Python 2 and has virtually disappeared.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pypthon-0.1.0.tar.gz
.
File metadata
- Download URL: pypthon-0.1.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7530a796f5db9aca25b5722e9c3a5410034aeda021414fe151374e1f3350f30b |
|
MD5 | 5add30ae26685532909f9dd01f2ec31c |
|
BLAKE2b-256 | 066a0237f9926e397d6a937848f68329dabdbab99960c22de32dfbc8bcdfbc01 |
File details
Details for the file pypthon-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pypthon-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10a6347d0822bbc48b304edd0096d646579ae71c5b935eb42cb802cb9fdd9ab1 |
|
MD5 | dce5796dc404127225d241d6cb00dda4 |
|
BLAKE2b-256 | a3855ebf1c96ca32dc9ce4e3e46a3c769de1b97fa252bfdbf2ed8562a3872834 |