Creating UUIDs (GUIDs) portably
Thomas Heller
theller at python.net
Mon Feb 24 09:31:35 EST 2003
"Mark McEahern" <marklists at mceahern.com> writes:
> [Ondrej Krajicek]
> > Is there any Python module or (at least) Linux library,
> > which is able to create GUIDs (DCE RPC UUIDs
> > with proper flags set)?
>
> You could write a Python Extension to wrap libuuid.so.
>
Nice use-case for ctypes on linux:
thomas at susi:~ > python2.3
Python 2.3a1 (#2, Jan 25 2003, 01:52:52)
[GCC 2.95.2 19991024 (release)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import CDLL, c_string
>>> uuid = c_string("\000" * 16)
>>> lib = CDLL("/lib/libuuid.so.1")
>>> lib.uuid_generate(uuid)
1263991427
>>> out = c_string("\000" * 36)
>>> lib.uuid_unparse(uuid, out)
36
>>> print out.value
fe59a066-5999-4cf9-a0cc-9f57564b83fa
>>>
Thomas
More information about the Python-list
mailing list