On Tue, Sep 10, 2013 at 10:39 AM, Shabda Raaj <sha...@agiliq.com> wrote:

> > https://github.com/webpy/webpy/blob/master/web/utils.py#L52
>
> Wow, thats better than the "bare" bunch impl. Gonna use it now.
>
> Unrelated tip:
>
> Here is a one liner I use to generate passwords and other random strings.
>
> ''.join(random.choice(string.ascii_uppercase + string.digits) for x in
> range(N))
>

I use it very often. Here is my random-password script.

$ cat ~/bin/random-password
#! /usr/bin/env python

import random
import sys
import string

try:
    n = int(sys.argv[1])
 except IndexError:
    n = 20

print("".join(random.choice(string.ascii_letters) for i in range(n)))

Anand
_______________________________________________
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers

Reply via email to