Obfuscated Python: fun with shadowing builtins

Michael Hoffman cam.ac.uk at mh391.invalid
Wed Mar 16 20:48:52 EST 2005


I was compelled to write this today for some reason.

builtins = """__import__ abs basestring bool callable chr
classmethod cmp compile complex delattr dict dir
divmod enumerate eval execfile file filter
float frozenset getattr globals hasattr hash help hex
id input int isinstance issubclass iter len list
locals long map max
min object oct open ord pow
property range raw_input reduce
reload repr reversed round set setattr
slice sorted staticmethod str
sum super tuple type unichr
unicode vars xrange zip"""

unicode=lambda long:apply(long.split);float=lambda int:getattr(__builtins__,unicode(builtins)[15])(unicode(builtins)[int]);staticmethod,long=lambda long:float(int(str(1)*int(2))*unicode(builtins).index(long.__name__)), lambda staticmethod:unicode(apply(builtins.splitlines)[staticmethod]);int=float(0)(apply(str).join(unicode(builtins)[staticmethod(bool)(long(2*int))][staticmethod(bool)(long(2*int+1))] for int in staticmethod(classmethod)(staticmethod(bool)(long(-1)))))

Enjoy ;)
-- 
Michael Hoffman



More information about the Python-list mailing list