Python 3.7+uuidterm
uuid.SafeUUID
the UUID class
An enumeration of three values (safe, unsafe, unknown) held in is_safe: whether the system guaranteed the UUID's uniqueness across concurrent processes.
Syntax
uuid.SafeUUID.safe | uuid.SafeUUID.unsafe | uuid.SafeUUID.unknown
Only uuid1() fills it in, when the system library can issue UUIDs without races between processes: for uuid4(), uuid6(), uuid7() and the rest is_safe is always SafeUUID.unknown, and that is no warning sign. The value depends on the OS and libraries, so unsafe on one machine and safe on another is normal. unknown has the value None, so if u.is_safe.value: cannot tell unknown from safe with its zero — compare with the enum member.
Examples
import uuid
print(list(uuid.SafeUUID)) # → [<SafeUUID.safe: 0>, <SafeUUID.unsafe: -1>, <SafeUUID.unknown: None>]
print(uuid.uuid4().is_safe) # → SafeUUID.unknown
print(uuid.uuid1().is_safe) # → ? SafeUUID.unsafe — зависит от ОС
See also
Open in the full glossarydocs.python.orgReport an inaccuracy