GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||
GeezerVison is showing docs.python.org — uuid — UUID objects according to RFC 4122
|
Field |
Meaning |
|
The first 32 bits of the UUID. |
|
The next 16 bits of the UUID. |
|
The next 16 bits of the UUID. |
|
The next 8 bits of the UUID. |
|
The next 8 bits of the UUID. |
|
The last 48 bits of the UUID. |
|
The 60-bit timestamp. |
|
The 14-bit sequence number. |
The UUID as a 32-character lowercase hexadecimal string.
The UUID as a 128-bit integer.
The UUID variant, which determines the internal layout of the UUID. This will be
one of the constants RESERVED_NCS, RFC_4122,
RESERVED_MICROSOFT, or RESERVED_FUTURE.
An enumeration of SafeUUID which indicates whether the platform
generated the UUID in a multiprocessing-safe way.
New in version 3.7.
The uuid module defines the following functions:
Get the hardware address as a 48-bit positive integer. The first time this runs, it may launch a separate program, which could be quite slow. If all attempts to obtain the hardware address fail, we choose a random 48-bit number with the multicast bit (least significant bit of the first octet) set to 1 as recommended in RFC 4122. “Hardware address” means the MAC address of a network interface. On a machine with multiple network interfaces, universally administered MAC addresses (i.e. where the second least significant bit of the first octet is unset) will be preferred over locally administered MAC addresses, but with no other ordering guarantees.
Changed in version 3.7: Universally administered MAC addresses are preferred over locally administered MAC addresses, since the former are guaranteed to be globally unique, while the latter are not.
Generate a UUID from a host ID, sequence number, and the current time. If node
is not given, getnode() is used to obtain the hardware address. If
clock_seq is given, it is used as the sequence number; otherwise a random
14-bit sequence number is chosen.
Generate a UUID based on the MD5 hash of a namespace identifier (which is a UUID) and a name (which is a string).
Generate a random UUID.
Generate a UUID based on the SHA-1 hash of a namespace identifier (which is a UUID) and a name (which is a string).
The uuid module defines the following namespace identifiers for use with
uuid3() or uuid5().
When this namespace is specified, the name string is a fully qualified domain name.
When this namespace is specified, the name string is a URL.
When this namespace is specified, the name string is an ISO OID.
When this namespace is specified, the name string is an X.500 DN in DER or a text output format.
The uuid module defines the following constants for the possible values
of the variant attribute:
Reserved for NCS compatibility.
Reserved for Microsoft compatibility.
Reserved for future definition.
See also
This specification defines a Uniform Resource Name namespace for UUIDs, the internal format of UUIDs, and methods of generating UUIDs.
Here are some examples of typical usage of the uuid module:
>>> import uuid >>> # make a UUID based on the host ID and current time >>> uuid.uuid1() UUID('a8098c1a-f86e-11da-bd1a-00112444be1e') >>> # make a UUID using an MD5 hash of a namespace UUID and a name >>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org') UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e') >>> # make a random UUID >>> uuid.uuid4() UUID('16fd2706-8baf-433b-82eb-8c7fada847da') >>> # make a UUID using a SHA-1 hash of a namespace UUID and a name >>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org') UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d') >>> # make a UUID from a string of hex digits (braces and hyphens ignored) >>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}') >>> # convert a UUID to a string of hex digits in standard form >>> str(x) '00010203-0405-0607-0809-0a0b0c0d0e0f' >>> # get the raw 16 bytes of the UUID >>> x.bytes b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f' >>> # make a UUID from a 16-byte string >>> uuid.UUID(bytes=x.bytes) UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')