[BangPypers] Favorite tips/techniques

Anand Chitipothu anandology at gmail.com
Tue Sep 10 07:12:30 CEST 2013


On Tue, Sep 10, 2013 at 10:39 AM, Shabda Raaj <shabda at 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


More information about the BangPypers mailing list