Lines Matching full:uuid
2 :mod:`uuid` --- UUID objects according to RFC 4122
5 .. module:: uuid
6 :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[, bytes[, bytes_le[, fields[, int[, version]]]]]])
25 Create a UUID from either a string of 32 hexadecimal digits, a string of 16
33 expressions all yield the same UUID::
35 UUID('{12345678-1234-5678-1234-567812345678}')
36 UUID('12345678123456781234567812345678')
37 UUID('urn:uuid:12345678-1234-5678-1234-567812345678')
38 UUID(bytes='\x12\x34\x56\x78'*4)
39 UUID(bytes_le='\x78\x56\x34\x12\x34\x12\x78\x56' +
41 UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678))
42 UUID(int=0x12345678123456781234567812345678)
45 The *version* argument is optional; if given, the resulting UUID will have its
49 :class:`UUID` instances have these read-only attributes:
52 .. attribute:: UUID.bytes
54 The UUID as a 16-byte string (containing the six integer fields in big-endian
58 .. attribute:: UUID.bytes_le
60 The UUID as a 16-byte string (with *time_low*, *time_mid*, and *time_hi_version*
64 .. attribute:: UUID.fields
66 A tuple of the six integer fields of the UUID, which are also available as six
72 | :attr:`time_low` | the first 32 bits of the UUID |
74 | :attr:`time_mid` | the next 16 bits of the UUID |
76 | :attr:`time_hi_version` | the next 16 bits of the UUID |
78 | :attr:`clock_seq_hi_variant` | the next 8 bits of the UUID |
80 | :attr:`clock_seq_low` | the next 8 bits of the UUID |
82 | :attr:`node` | the last 48 bits of the UUID |
90 .. attribute:: UUID.hex
92 The UUID as a 32-character hexadecimal string.
95 .. attribute:: UUID.int
97 The UUID as a 128-bit integer.
100 .. attribute:: UUID.urn
102 The UUID as a URN as specified in RFC 4122.
105 .. attribute:: UUID.variant
107 The UUID variant, which determines the internal layout of the UUID. This will be
112 .. attribute:: UUID.version
114 The UUID version number (1 through 5, meaningful only when the variant is
117 The :mod:`uuid` module defines the following functions:
134 Generate a UUID from a host ID, sequence number, and the current time. If *node*
144 Generate a UUID based on the MD5 hash of a namespace identifier (which is a
145 UUID) and a name (which is a string).
152 Generate a random UUID.
159 Generate a UUID based on the SHA-1 hash of a namespace identifier (which is a
160 UUID) and a name (which is a string).
164 The :mod:`uuid` module defines the following namespace identifiers for use with
189 The :mod:`uuid` module defines the following constants for the possible values
200 Specifies the UUID layout given in :rfc:`4122`.
215 :rfc:`4122` - A Universally Unique IDentifier (UUID) URN Namespace
225 Here are some examples of typical usage of the :mod:`uuid` module::
227 >>> import uuid
229 >>> # make a UUID based on the host ID and current time
230 >>> uuid.uuid1()
231 UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')
233 >>> # make a UUID using an MD5 hash of a namespace UUID and a name
234 >>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')
235 UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')
237 >>> # make a random UUID
238 >>> uuid.uuid4()
239 UUID('16fd2706-8baf-433b-82eb-8c7fada847da')
241 >>> # make a UUID using a SHA-1 hash of a namespace UUID and a name
242 >>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')
243 UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d')
245 >>> # make a UUID from a string of hex digits (braces and hyphens ignored)
246 >>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}')
248 >>> # convert a UUID to a string of hex digits in standard form
252 >>> # get the raw 16 bytes of the UUID
256 >>> # make a UUID from a 16-byte string
257 >>> uuid.UUID(bytes=x.bytes)
258 UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')