• Home
  • Raw
  • Download

Lines Matching refs:UUID

1 :mod:`uuid` --- UUID objects according to RFC 4122
5 :synopsis: UUID objects (universally unique identifiers) according to RFC 4122
13 This module provides immutable :class:`UUID` objects (the :class:`UUID` class)
19 a UUID containing the computer's network address. :func:`uuid4` creates a
20 random UUID.
23 .. class:: UUID(hex=None, bytes=None, bytes_le=None, fields=None, int=None, version=None)
25 Create a UUID from either a string of 32 hexadecimal digits, a string of 16
32 expressions all yield the same UUID::
34 UUID('{12345678-1234-5678-1234-567812345678}')
35 UUID('12345678123456781234567812345678')
36 UUID('urn:uuid:12345678-1234-5678-1234-567812345678')
37 UUID(bytes=b'\x12\x34\x56\x78'*4)
38 UUID(bytes_le=b'\x78\x56\x34\x12\x34\x12\x78\x56' +
40 UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678))
41 UUID(int=0x12345678123456781234567812345678)
44 The *version* argument is optional; if given, the resulting UUID will have its
48 Comparison of UUID objects are made by way of comparing their
49 :attr:`UUID.int` attributes. Comparison with a non-UUID object
54 represent the UUID.
56 :class:`UUID` instances have these read-only attributes:
58 .. attribute:: UUID.bytes
60 The UUID as a 16-byte string (containing the six integer fields in big-endian
64 .. attribute:: UUID.bytes_le
66 The UUID as a 16-byte string (with *time_low*, *time_mid*, and *time_hi_version*
70 .. attribute:: UUID.fields
72 A tuple of the six integer fields of the UUID, which are also available as six
78 | :attr:`time_low` | the first 32 bits of the UUID |
80 | :attr:`time_mid` | the next 16 bits of the UUID |
82 | :attr:`time_hi_version` | the next 16 bits of the UUID |
84 | :attr:`clock_seq_hi_variant` | the next 8 bits of the UUID |
86 | :attr:`clock_seq_low` | the next 8 bits of the UUID |
88 | :attr:`node` | the last 48 bits of the UUID |
96 .. attribute:: UUID.hex
98 The UUID as a 32-character hexadecimal string.
101 .. attribute:: UUID.int
103 The UUID as a 128-bit integer.
106 .. attribute:: UUID.urn
108 The UUID as a URN as specified in RFC 4122.
111 .. attribute:: UUID.variant
113 The UUID variant, which determines the internal layout of the UUID. This will be
118 .. attribute:: UUID.version
120 The UUID version number (1 through 5, meaningful only when the variant is
140 Generate a UUID from a host ID, sequence number, and the current time. If *node*
150 Generate a UUID based on the MD5 hash of a namespace identifier (which is a
151 UUID) and a name (which is a string).
158 Generate a random UUID.
165 Generate a UUID based on the SHA-1 hash of a namespace identifier (which is a
166 UUID) and a name (which is a string).
206 Specifies the UUID layout given in :rfc:`4122`.
221 :rfc:`4122` - A Universally Unique IDentifier (UUID) URN Namespace
235 >>> # make a UUID based on the host ID and current time
237 UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')
239 >>> # make a UUID using an MD5 hash of a namespace UUID and a name
241 UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')
243 >>> # make a random UUID
245 UUID('16fd2706-8baf-433b-82eb-8c7fada847da')
247 >>> # make a UUID using a SHA-1 hash of a namespace UUID and a name
249 UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d')
251 >>> # make a UUID from a string of hex digits (braces and hyphens ignored)
252 >>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}')
254 >>> # convert a UUID to a string of hex digits in standard form
258 >>> # get the raw 16 bytes of the UUID
262 >>> # make a UUID from a 16-byte string
263 >>> uuid.UUID(bytes=x.bytes)
264 UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')