Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ganeshkumartk/1line
Convert any Python file into a single line of code.
https://github.com/ganeshkumartk/1line
lambda lambda-calculus oneliner oruline pip pip3 pypi pypi-packages pypi-source python python-script
Last synced: 10 days ago
JSON representation
Convert any Python file into a single line of code.
- Host: GitHub
- URL: https://github.com/ganeshkumartk/1line
- Owner: ganeshkumartk
- License: mit
- Created: 2019-06-11T15:03:47.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-06-20T17:37:33.000Z (over 5 years ago)
- Last Synced: 2024-11-16T10:15:43.028Z (2 months ago)
- Topics: lambda, lambda-calculus, oneliner, oruline, pip, pip3, pypi, pypi-packages, pypi-source, python, python-script
- Language: Python
- Size: 99.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Oruline !
=========![PyPI](https://img.shields.io/pypi/v/oruline.svg)
![GitHub](https://img.shields.io/github/license/coderganesh/1line.svg?style=plastic)
![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)
[![forthebadge](https://forthebadge.com/images/badges/powered-by-netflix.svg)](http://forthebadge.com)
![PyPI - Implementation](https://img.shields.io/pypi/implementation/c.svg)
[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/CoDeRgAnEsh)Convert any Python file into a single line of code which has the same functionality.
"Oru" means *One/Single* (in tamil). So, Single line == Oruline !No newlines allowed. No semicolons allowed, either.
User Installation and Usage
---Install via `pip` from PyPI:
```sh
$ pip install oruline
```Use either the command line function or the Python module:
```sh
$ echo "def f(x):\n print x\nf(4)" > sandbox.py
$ oruliner sandbox.py --debug
$ oruliner sandbox_ol.py
``````python
from oruliner import oruline
oruline("def f(x):\n print x\nf(4)")
```Examples
--------**Before:**
```python
x = 3
y = 4
print (x < y < 5)
```**After:**
```python
(lambda __builtin__: (lambda __print, __y, d: [[__print(d.x n:
print "Too big! Try again!"
elif user_input < n:
print "Too small! Try again!"
else:
print "You win!"
return True
guess_my_number(42)
```**After:**
```python
(lambda __builtin__: (lambda __print, __y, d: [(lambda ___: None)(d.guess_my_number(42)) for d.guess_my_number in [(lambda n:[(__y(lambda __this: (lambda d: (lambda __after: [(lambda __after: (lambda ___: __after(d))(__print('Not a positive integer!')) if (d.len(d.user_input)==0 or (not d.user_input.isdigit())) else [(lambda __after: (lambda ___: __after(d))(__print('Too big! Try again!')) if d.user_input>d.n else (lambda __after: (lambda ___: __after(d))(__print('Too small! Try again!')) if d.user_input