Platform-independent GUID creation?

Irmen de Jong usenet at NOSPAM-irmen.cjb.net
Sat Dec 22 07:56:56 EST 2001


> >Does anyone have a readily-portable equivalent to the
pythoncom.CreateGuid()
> >function?
>
> The problem is that the DCE/OSF GUID standard specifies using the MAC
> address of the network card as part of a GUID.  There isn't a portable
> way to get that, unfortunately.


I've crafted my own Guid function, and it is used heavily in Pyro
(pyro.sourceforge.net).
It uses the machine's IP address instead of the MAC address, and adds the
Pid and
some other stuff (timestamp, random number).

I don't know the DCE standard, but I do think that my routine is fairly
"safe", so to speak.
At least it is portable across all Python implementations, but the machine
needs to
have an IP address. A physical MAC address is not requiered, so it should
work
nicely on modem-only machines.

Irmen de Jong






More information about the Python-list mailing list