Skip to main content

Installation

To install from Pypi:

pip install py1cmd

Introduction

One should use the right tool for the right task. But Learning 300 tools is counterproductive, so one needs a fallback. To be generic enough that fallback must be scriptable. So we have AWK, Perl, Sed, TCL… and their read-only languages.

Enters py1, it aims at being a “Python AWK”. It can be used in two modes.

In both modes indents and dedents can be replaced with “{{” and “}}”, line feeds can be replaced with “;”.

Minimalist

To use this mode:

py1 "python_one_liner"

“{{” and “}}” can be used instead of indent/dedent, and “;” instead of line feed eg:

py1 "import sys ; if True: {{ print(sys.version) }}"

AWK-like

In this mode, py1 generates a python script wrapping your code and defining a convenient set of 1&2-letters variables and functions.

To use this mode, pass any of --begin/-b, --each-line/-l, --end/-e.

For example, to count lines matching '$a*^':

py1 --begin "count=0" --each-line "if M('$a*^'): count += 1"
    --end "P(count)"

To learn more you can read the list of one letter functions and variables or just look at examples and figure out the rest.

Sustainable hacking

If you find yourself writing a longer than readable one-liner, you can transform it in regular Python code, easily refactored for later reuse. Just add --dump-code.

More!

Interested? You can install with:

pip install py1cmd

To learn more you can read the list of one letter functions and variables or just look at examples and figure out the rest.

How to contribute?

I wrote some advices and documented the internals here. Feel free to just contact unbrice.

Metadata

Release files for py1cmd 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py1cmd 0.1
File Size Uploaded
py1cmd-0.1.tar.gz 18.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py1cmd 0.1
File Interpreter ABI Platform
py1cmd-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 33.7 kB

Release files / py1cmd-0.1.tar.gz

Download URL py1cmd-0.1.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d342f66a2398de378dd8b4c438994a6e52f7c5eb8fb1059cabb725bf019bacb6
BLAKE2b-256 checksum
How to use checksums
85b42ff09b4142272d0ad6c62ac44be9edb21b04f5af6a994a457aa244f8b70a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / py1cmd-0.1-py3-none-any.whl

Download URL py1cmd-0.1-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
efe9151430bcbf49f3fb4b22ec541e3980b220e708f229935b88be9423458472
BLAKE2b-256 checksum
How to use checksums
21f21e9f058038eacbe879c0b35585945ac9e702b1ae65347fc71bdf025d4c23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.3

2 release files

0.2

2 release files

This release

0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page