Lines Matching full:uuid

1 :mod:`uuid` --- UUID objects according to :rfc:`4122`
4 .. module:: uuid
5 :synopsis: UUID objects (universally unique identifiers) according to RFC 4122
9 **Source code:** :source:`Lib/uuid.py`
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 not return a "safe" UUID. A safe UUID is one which is generated using
25 UUID. All instances of :class:`UUID` have an :attr:`is_safe` attribute
26 which relays any information about the UUID's safety, using this enumeration:
34 The UUID was generated by the platform in a multiprocessing-safe way.
38 The UUID was not generated in a multiprocessing-safe way.
42 The platform does not provide information on whether the UUID was
45 .. class:: UUID(hex=None, bytes=None, bytes_le=None, fields=None, int=None, version=None, *, is_saf…
47 Create a UUID from either a string of 32 hexadecimal digits, a string of 16
55 expressions all yield the same UUID::
57 UUID('{12345678-1234-5678-1234-567812345678}')
58 UUID('12345678123456781234567812345678')
59 UUID('urn:uuid:12345678-1234-5678-1234-567812345678')
60 UUID(bytes=b'\x12\x34\x56\x78'*4)
61 UUID(bytes_le=b'\x78\x56\x34\x12\x34\x12\x78\x56' +
63 UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678))
64 UUID(int=0x12345678123456781234567812345678)
67 The *version* argument is optional; if given, the resulting UUID will have its
71 Comparison of UUID objects are made by way of comparing their
72 :attr:`UUID.int` attributes. Comparison with a non-UUID object
75 ``str(uuid)`` returns a string in the form
77 represent the UUID.
79 :class:`UUID` instances have these read-only attributes:
81 .. attribute:: UUID.bytes
83 The UUID as a 16-byte string (containing the six integer fields in big-endian
87 .. attribute:: UUID.bytes_le
89 The UUID as a 16-byte string (with *time_low*, *time_mid*, and *time_hi_version*
93 .. attribute:: UUID.fields
95 A tuple of the six integer fields of the UUID, which are also available as six
101 | :attr:`time_low` | the first 32 bits of the UUID |
103 | :attr:`time_mid` | the next 16 bits of the UUID |
105 | :attr:`time_hi_version` | the next 16 bits of the UUID |
107 | :attr:`clock_seq_hi_variant` | the next 8 bits of the UUID |
109 | :attr:`clock_seq_low` | the next 8 bits of the UUID |
111 | :attr:`node` | the last 48 bits of the UUID |
119 .. attribute:: UUID.hex
121 The UUID as a 32-character hexadecimal string.
124 .. attribute:: UUID.int
126 The UUID as a 128-bit integer.
129 .. attribute:: UUID.urn
131 The UUID as a URN as specified in :rfc:`4122`.
134 .. attribute:: UUID.variant
136 The UUID variant, which determines the internal layout of the UUID. This will be
141 .. attribute:: UUID.version
143 The UUID version number (1 through 5, meaningful only when the variant is
146 .. attribute:: UUID.is_safe
149 generated the UUID in a multiprocessing-safe way.
153 The :mod:`uuid` module defines the following functions:
178 Generate a UUID from a host ID, sequence number, and the current time. If *node*
188 Generate a UUID based on the MD5 hash of a namespace identifier (which is a
189 UUID) and a name (which is a string).
196 Generate a random UUID.
203 Generate a UUID based on the SHA-1 hash of a namespace identifier (which is a
204 UUID) and a name (which is a string).
208 The :mod:`uuid` module defines the following namespace identifiers for use with
233 The :mod:`uuid` module defines the following constants for the possible values
244 Specifies the UUID layout given in :rfc:`4122`.
259 :rfc:`4122` - A Universally Unique IDentifier (UUID) URN Namespace
269 Here are some examples of typical usage of the :mod:`uuid` module::
271 >>> import uuid
273 >>> # make a UUID based on the host ID and current time
274 >>> uuid.uuid1()
275 UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')
277 >>> # make a UUID using an MD5 hash of a namespace UUID and a name
278 >>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')
279 UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')
281 >>> # make a random UUID
282 >>> uuid.uuid4()
283 UUID('16fd2706-8baf-433b-82eb-8c7fada847da')
285 >>> # make a UUID using a SHA-1 hash of a namespace UUID and a name
286 >>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')
287 UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d')
289 >>> # make a UUID from a string of hex digits (braces and hyphens ignored)
290 >>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}')
292 >>> # convert a UUID to a string of hex digits in standard form
296 >>> # get the raw 16 bytes of the UUID
300 >>> # make a UUID from a 16-byte string
301 >>> uuid.UUID(bytes=x.bytes)
302 UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')