NoName schrieb: > Perl: > @char=("A".."Z","a".."z",0..9); > do{print join("",@char[map{rand @char}(1..8)])}while(<>); > > !!generate passwords untill U press ctrl-z > > > > Python (from CookBook): > > from random import choice > import string > print ''.join([choice(string.letters+string.digits) for i in > range(1,8)]) > > !!generate password once :( > > who can write this smaller or without 'import'? >
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. :) -- Stargaming -- http://mail.python.org/mailman/listinfo/python-list