Message198943
When you try to use uuid.UUID() without arguments you get a TypeError exception saying that you can actually use an integer (while you cannot).
Python 2.6.8 (default, Apr 26 2013, 16:24:53)
[GCC 4.6.3] on linux2
>>> uuid.UUID()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/uuid.py", line 129, in __init__
raise TypeError('need one of hex, bytes, bytes_le, fields, or int')
TypeError: need one of hex, bytes, bytes_le, fields, or int
>>> uuid.UUID(uuid.uuid4().int)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/uuid.py", line 131, in __init__
hex = hex.replace('urn:', '').replace('uuid:', '')
AttributeError: 'long' object has no attribute 'replace'
So, let's check with an integer - maybe an int has 'replace'.
>>> uuid.UUID(1231231)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/uuid.py", line 131, in __init__
hex = hex.replace('urn:', '').replace('uuid:', '')
AttributeError: 'int' object has no attribute 'replace'
No, it doesn't. Anyway, with a propery hex value, it works (of course!).
>>> uuid.UUID(uuid.uuid4().hex)
UUID('89b1283d-c32e-4b8a-a9e3-a699445fdd4d') |
|
Date |
User |
Action |
Args |
2013-10-04 11:18:10 | makronized | set | recipients:
+ makronized, docs@python |
2013-10-04 11:18:10 | makronized | set | messageid: <1380885490.13.0.480584034262.issue19164@psf.upfronthosting.co.za> |
2013-10-04 11:18:10 | makronized | link | issue19164 messages |
2013-10-04 11:18:09 | makronized | create | |
|