From: David W. <wo...@cs...> - 2008-08-25 20:54:28
|
On 25-Aug-08, at 3:19 PM, Yuri Takhteyev wrote: >> def getRandomToken(n=10, seed=RND_SEED): >> random.seed(seed) >> return "".join([chr(random.randint(97, 122)) for i in range(n)]) > .... > return "".join([chr(random.randint(LOWERCASE_ASCII_A, > LOWERCASE_ASCII_Z)) for i in range(n)]) > And then suddenly "abcdefghijklmnopqrstuvwxyz"[random.randint(1,26)] > doesn't look so verbose. :) Now, if we're going to be arguing about generating universally unique identifiers... I feel like I should chime in with one module I've been making heavy use of recently: uuid! >>> from uuid import uuid4 >>> uuid4().hex '6908a7924f4d46bf915da19876c93368' >>> |