Python Syntax

PythonSyntax works for me because of :

I don't suppose that there is any chance of an ObfuscatedPython Contest, is there?

Mmm... who can guess what the following code prints?

print (lambda x:"print %s(%s)"%(x,repr(x)))('(lambda x:"print %s(%s)"%(x,repr(x)))')

Neat, but not surprising. I like this old one from TimPeters

a=range(1,11);(eval('a.'+[].__methods__[-2])()or a)

Just how old would that be? '__methods__' appears not to exist in Python 2.3...

Maybe the following works in newer Python:

a=range(1,11);(eval('a.'+dir([])[-2])()or a)

and of course ...

#!/usr/local/bin/python -- -export-a-crypto-system-sig -RSA-in-4-lines-Python
from sys import*;a=argv;[s,p,q]=filter(lambda x:x[:1]!=
'-',a);d='-d'in a;e,n=long(p,16),long(q,16);l=(len(q)+1)/2;o,inb=l-d,l-1+d
while s:s=stdin.read(inb);s and map(stdout.write,map(lambda i,b=pow(reduce(
lambda x,y:(x<<8L)+y,map(ord,s)),e,n):chr(b>>8*i&255),range(o-1,-1,-1)))

Wear that on a t-shirt in asia and you're stylin'!

Oops, is this wiki now a munition?

Nah, they relaxed the export prohibitions.


See PythonWhiteSpaceDiscussion, PythonVsRuby