Permutations
1 import itertools
2 from string import ascii_lowercase
3 import twitter
4
5 count = 0
6
7 api = twitter.Api()
8
9
10 complete_charset = ascii_lowercase + '_0123456789'
11
12 product=itertools.product(list(complete_charset), repeat=3)
13
14 for s in product:
15 user = ''.join(s)
16 try:
17 api.GetUser(user)
18 except ValueError:
19 print user + "is still available"
20 count += 1
21 print count + "of 50653"
References
http://docs.python.org/library/itertools.html
PythonTutorial (last edited 2011-02-12 01:13:24 by 67)