> Is there a GUID or UUID generator in Python?

Batteries included ...

uuid module
http://www.python.org/doc/2.5/whatsnew/modules.html
http://www.faqs.org/rfcs/rfc4122.html

Generates universally unique identifiers (UUIDs) according to RFC 4122.
The RFC defines several different UUID versions that are generated from
a starting string, from system properties, or purely randomly. This
module contains a UUID class and functions named uuid1(), uuid3(),
uuid4(), and uuid5() to generate different versions of UUID. (Version 2
UUIDs are not specified in RFC 4122 and are not supported by this
module.)

Examples:

import uuid

# make a UUID based on the host ID and current time
uuid.uuid1()
UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')

# make a UUID using an MD5 hash of a namespace UUID and a name
uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')
UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')

# make a random UUID
uuid.uuid4()
UUID('16fd2706-8baf-433b-82eb-8c7fada847da')

# make a UUID using a SHA-1 hash of a namespace UUID and a name
uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')
UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d')

Malcolm

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to