Skip to main content

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

pypthon-0.1.0.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

pypthon-0.1.0-py3-none-any.whl (18.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page