Random passwords generation (Python vs Perl) =)

Szabolcs Nagy nszabolcs at gmail.com
Mon Jan 29 11:38:13 EST 2007


> If you really want a hack, here it is:
>
> while 1:print
> ''.join(__import__('random').choice(__import__('string').letters+'1234567890')
> for x in xrange(8)),;n=raw_input()
>
> This is a one-liner (though mail transmission may split it up), no
> import statements. If someone can come up with an even smaller version,
> feel free to post. :)

while 
1:i=__import__;print''.join(i('random').choice(i('string').letters
+'1234567890')for x in range(8)),;raw_input()

same but shorter:
i = __import__;
xrange -> range (why use xrange? range is faster and simpler for small 
ranges)
n =(not needed)




More information about the Python-list mailing list