generating uuids / guids

J

Jon Perez

Is there a Python function that works on all platforms (not just Win32)
to generate such in the DCE / Microsoft format?

If not present, this looks like it would be a very Pythonic addition
to the standard library.
 
P

Paul Rubin

Jon Perez said:
Is there a Python function that works on all platforms (not just Win32)
to generate such in the DCE / Microsoft format?

If not present, this looks like it would be a very Pythonic addition
to the standard library.

Why do you say that adding Windows GUID generation to non-Windows
platforms would be Pythonic? Yeesh.
 
J

Jon Perez

The DCE/OSF uuids I see in Linux ('uuidgen' command)and the Windows
guids look like they are the same format. They have the same number
of hex digits (although their generation methods may be different).
It would be good to have the same function interface for either.
 
A

Aahz

Is there a Python function that works on all platforms (not just Win32)
to generate such in the DCE / Microsoft format?

If not present, this looks like it would be a very Pythonic addition
to the standard library.

Sure it would. Best way to start is to create a stand-alone third-party
library that implements the full DCE spec. Once it has proven its
utility and stability, send a note to python-dev suggesting that it be
added.

Keep in mind that UUID generation is a somewhat complex and tricky
business will likely require some kind of C library support (to get the
MAC address, to check if there's already a system-level UUID/GUID
generator present, to provide a "good" UUID if there's no network card,
and so on).
--
Aahz ([email protected]) <*> http://www.pythoncraft.com/

"To me vi is Zen. To use vi is to practice zen. Every command is a
koan. Profound to the user, unintelligible to the uninitiated. You
discover truth everytime you use it." (e-mail address removed)
 
J

Jonathan P.

Sure it would. Best way to start is to create a stand-alone third-party
library that implements the full DCE spec. Once it has proven its
utility and stability, send a note to python-dev suggesting that it be
added.

Keep in mind that UUID generation is a somewhat complex and tricky
business will likely require some kind of C library support (to get the
MAC address, to check if there's already a system-level UUID/GUID
generator present, to provide a "good" UUID if there's no network card,
and so on).

Aren't there already uuid generation routines in both Linux and
Windows and wouldn't all that's needed be to wrap them in Python?
 
A

Aahz

Aren't there already uuid generation routines in both Linux and
Windows and wouldn't all that's needed be to wrap them in Python?

Absolutely. However, I don't know if any of them are cross-platform,
and if you have any intention of getting this into the standard library,
it'll need to be readily available on any platform with an ANSI C
compiler. Packaging is *NOT* trivial, and that's precisely why it's
rare to see code added to the standard library until it has proven
itself.

If you can find a way to implement this in pure Python, that probably
gives the biggest boost to the likelihood of getting into the standard
library. Python 2.4 is too far along to add this; that gives you 12-18
months for working this into usable shape.
--
Aahz ([email protected]) <*> http://www.pythoncraft.com/

"To me vi is Zen. To use vi is to practice zen. Every command is a
koan. Profound to the user, unintelligible to the uninitiated. You
discover truth everytime you use it." (e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top