One-Liner Generator for Python
A simple script that converts python scripts into one-liner.
Install
pip install OLG4P
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('')
Generated:
[(itertools := __import__('itertools')), (random := __import__('random')), [(__ol_assign_tmp_nxazjlgisn := (0, 2)), (y := __ol_assign_tmp_nxazjlgisn[0]), (h := __ol_assign_tmp_nxazjlgisn[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())]]
Limitation
This script requires python3.9+. Many statements are not convertable.
Here are the statements that have already been implemented.
| statement | example |
|---|---|
| Expr | print((1+1)*2) |
| Assign | a=1a,b=b,a |
| AugAssign | a*=1 |
| If | if a==0: ...elif a>1: ...else: ... |
| For | for i in range(10): ...else: ... |
| While | while a<100: ...else: ... |
| Break | break |
| Continue | continue |
| Pass | while 1: pass |
| Import 1 | import mathimport os,sysimport numpy as np |
| FunctionDef | def func(a,*args): ... |
| Return | return None |
| Global | global a |
Remarks:
- 'from-import' is not implmented.
Dependencies
- CPython >= 3.9
Metadata
Release files for OLG4P 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| OLG4P-0.2-py3-none-any.whl | Python 3 | none | any | Details |
Release files / OLG4P-0.2-py3-none-any.whl
| Download URL | OLG4P-0.2-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
52086ddb239020bd6e5209fc63d6cc6e2c8a94059234c1ca6abd021fb7c40320
|
|
BLAKE2b-256 checksum How to use checksums |
423bde57171944cc2cdf892a61af39429fabaf5b6887f5efd3644529a7338f70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Security for OLG4P 0.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.