Convert Python 3 code into one line, inspired by the Python 2 counterpart
This project is currently not completed!
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?
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)),)),)