Avoiding local variable declarations?

Mark Wooding mdw at distorted.org.uk
Fri Nov 14 19:08:51 CET 2008


Chris Mellon <arkanes at gmail.com> wrote:

> Any time you port between languages, it's rarely a good idea to just
> convert code verbatim. For example:
>
> import random, string
> def random_char():
>     return random.choice(string.ascii_letters + string.digits)

Note that this code doesn't preserve the output distribution of the
original, for which once expects half the characters to be numeric.  I
don't know if that's relevant; in fact I suspect that the original was
buggy.

-- [mdw]



More information about the Python-list mailing list