Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python 3 Onelinerizer

Convert Python 3 code into one line, inspired by the Python 2 counterpart

This project is currently not completed!

Motivation

Modern software enginerring has been long emphasizing the composablilty of programs. As a modern programming language, Python is the ideal way to achieve the goal. But how to prove that?

Supported Statements

Import

Before:

import sys, pandas as pd
sys.stderr.write(repr(pd.read_csv('test.txt')))

After:

(lambda sys, pd: (sys.stderr.write(repr(pd.read_csv('test.txt')))))(__import__("sys"), __import__("pandas"))

Assign

Before:

a, b = 1, 2
print(a + b)

After:

next((print(a + b) for a, b in ((1, 2),)),)

Function Definition

Before:

def foo(arg1, arg2, *args, **kwargs):
    print(arg1, arg2, args, kwargs)
foo(1, 2, 3, 4, bar=5, baz=6)

After:

next((foo(1, 2, 3, 4, bar=5, baz=6) for foo in ((lambda arg1, arg2, *args, **kwargs: print(arg1, arg2, args, kwargs)),)),)

About

Convert Python 3 code into one line (WIP)

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages