[Tutor] Obfuscated Python [was Long Lines techniques]

Steven D'Aprano steve at pearwood.info
Fri Dec 14 00:35:43 EST 2018


On Thu, Dec 13, 2018 at 11:07:59PM -0500, Avi Gross wrote:

> Python may claim to be straightforward but I can easily see ways
> to fool people in python too with dunder methods or function closures or
> decorators or ...

Dunder methods shouldn't fool anyone. Each dunder method has a 
straightforward use, and most of the time you can guess that they do. 
__add__ implements the + operator, etc.

Closures and decorators can be abused, as can anything. One can write 
obfuscated code in any language. Here's some amusing obfuscated Python:

https://www.reddit.com/r/Python/comments/i1qgp/reduce_and_lambda_two_great_tastes_that_taste/

https://mail.python.org/pipermail/python-list/2013-October/658470.html

Anyone else want to share some obfuscated Python code?



-- 
Steve


More information about the Tutor mailing list