Hi list. I have downloaded some code from useless python that was writen buy a
guy named Sammy Mannaert. The code should show that python can be
unreadable, and it really is...
Can anyone explain to me how does this thing works ??
Here is the code (it prints "python readable ?"):
f=lambda x="8<:477\02092020162\020\037",y="01001000110100101":reduce(lambda
x,y:x+y,map(lambda y,x:chr(ord(y)*2+x),x,map(int,y)));print f();
(it all should be in one line)
Maybe this helps, I just pulled it apart from the inside:
# The original
f=lambda x="8<:477\02092020162\020\037",y="01001000110100101":reduce(lambda x,y:x+y,map(lambda y,x:chr(ord(y)*2+x),x,map(int,y)))
print f()
# A silly function to combine a number and a character making a new character def makeChar(y, x): return chr(ord(y)*2+x)
f=lambda x="8<:477\02092020162\020\037",y="01001000110100101":reduce(lambda x,y:x+y,map(makeChar,x,map(int,y)))
print f()
# Pull out x and y x="8<:477\02092020162\020\037" y="01001000110100101" yInts = map(int,y) # This turns y into a list of ints print 'yInts:', yInts f=lambda:reduce(lambda x,y:x+y,map(makeChar,x,yInts)) print f()
# Pull out the last lambda - this is the step that combines x and y into a list of chars chars = map(makeChar,x,yInts) print 'chars:', chars f=lambda:reduce(lambda x,y:x+y,chars) # This is just an obscure way to join the list into a string print f()
f = ''.join(chars) print f
Kent
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor