Python web-programming tools: several questions
John Hunter
jdhunter at ace.bsd.uchicago.edu
Mon Mar 10 10:22:44 EST 2003
More information about the Python-list mailing list
Mon Mar 10 10:22:44 EST 2003
- Previous message (by thread): interacting with gui-based programs
- Next message (by thread): Python web-programming tools: several questions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>>>>> "Giorgi" == Giorgi Lekishvili <gleki at gol.ge> writes: Giorgi> Which module should be used to generate random names for Giorgi> uploaded files? Must they be random? If all you want is to hide the filename, a oneway hash of the filename should suffice: >>> import md5 >>> m = md5.md5('somefile.dat') >>> print m.hexdigest() 927437f2e32cf2f913177b00312d972d If you truly want pseudo-random, you can generate a list of characters that you want to include for the filename, and then choose random elements from that list using the random module Here's an example to generate a length 10 filename import random chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890-_.' fname = ''.join([random.choice(chars) for i in range(10)]) John Hunter
- Previous message (by thread): interacting with gui-based programs
- Next message (by thread): Python web-programming tools: several questions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list