Convert python scripts into oneliner expression.
Project description
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
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
andyield from
try-except-finally
statementsraise
statementwith
statementassert
statementdel
statementasync-xxx
statementsmatch-case
statement (new in Python 3.10)type
statement (new in 3.12)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Oneliner-Py-1.0.0.tar.gz
(15.0 kB
view hashes)
Built Distribution
Close
Hashes for Oneliner_Py-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd59b8b0d2a2b1d4663f017f9995545870f39f197427e62ed611b14cea79d85f |
|
MD5 | 00552d46526d78d9aeabb01fa8067a2f |
|
BLAKE2b-256 | 01fdbb409da083f1623c79a40e61b8ec3c68cadc91f02c4a642ac88bd028016e |