What python can NOT do?
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Fri Sep 4 23:13:22 EDT 2009
On Fri, 04 Sep 2009 08:21:15 -0700, Mike Coleman wrote:
> It is true, though, that Python
> cannot be used to write arbitrarily complex one-liners, though.
Incorrect.
>>> exec "x=1\0while x < 5:\0 x+=1\0print x".replace('\0','\n')
5
Take (almost) any arbitrary piece of Python code. Replace all newlines by
nulls. Escape any quotation marks. Wrap the whole thing in quotes, and
pass it to exec as above, and you have an arbitrarily complex one-liner.
--
Steven
More information about the Python-list
mailing list