Skip to main content

oneliner-py

PyPI - Python Version PyPI - License Coverage Tests

Ruff Code style: black Imports: isort Checked with mypy

Convert python scripts into oneliner expression.

Usage

python3 -m oneliner [input file] -o [output file]

Or use python3 -m oneliner -h for help.

Example

InputFile:

import random
y,h=0,2
msg='hello_world'
while y<h*2:
    for x in range(len(msg)+2):
        print(random.choice('/\\'),end='')
    y+=1
    if y==h:
        print('\n %s '%msg)
    else:
        print('')

OutputFile:

[(importlib := __import__('importlib')), (itertools := __import__('itertools')), (random := importlib.import_module('random')), (__ol_assign_qqaleuwbod := (0, 2)), (y := __ol_assign_qqaleuwbod[0]), (h := __ol_assign_qqaleuwbod[1]), (msg := 'hello_world'), [[[print(random.choice('/\\'), end='') for x in range(len(msg) + 2)], y.__iadd__(1) if hasattr(y, '__iadd__') else (y := (y + 1)), print('\n %s ' % msg) if y == h else print('')] for _ in itertools.takewhile(lambda _: y < h * 2, itertools.count())]]

Install

pip install Oneliner-Py

Or

git clone https://github.com/yunline/Oneliner-Py.git
cd ./Oneliner-Py
python3 -m pip install .

Python Version Requirements

This converter requires python 3.10+
The converted scripts should be able to run on python 3.8+

Limitations

Following statements are not able to be converted as oneliner.

  • from-import * (from-import with star)
  • yield and yield from
  • try-except-finally statements
  • raise statement
  • with statement
  • assert statement
  • del statement
  • async-xxx statements
  • match-case statement (new in Python 3.10)
  • type statement (new in 3.12)

Release files for Oneliner-Py 1.2.2

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

Source distribution (sdist)

Source distribution for Oneliner-Py 1.2.2
File Size Uploaded
oneliner_py-1.2.2.tar.gz 21.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Oneliner-Py 1.2.2
File Interpreter ABI Platform
oneliner_py-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 47.3 kB

Release files / oneliner_py-1.2.2.tar.gz

Download URL oneliner_py-1.2.2.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0690af719596686c6ebf446f5d0c8545c8846cb68631fbffdd7a9c566ede9cfd
BLAKE2b-256 checksum
How to use checksums
b7d6378e251082864fb1ca522624613b0f645ce563618d0975508a1a0a9f5542
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2025.

Transparency log

Release files / oneliner_py-1.2.2-py3-none-any.whl

Download URL oneliner_py-1.2.2-py3-none-any.whl
Size 25.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d749c5524313874ae440a3ff8e5277feebcdd33c7321a35726c52478bf614ab
BLAKE2b-256 checksum
How to use checksums
b93af01efbb8bffd4bd0cf899d09f0e76414d0dfe1c2ba53761f61b11a8b646d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

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