GUID V4 - Random-Based Identifier (Recommended)
GUID v4 is the most widely used random-based identifier. Learn about its structure, collision probability, advantages and why it is recommended for general-purpose applications.
Generate UUIDs in Python with the standard uuid module for v4 and with uuid.uuid7() on Python 3.14 or newer, or a compatibility package on older runtimes.
import uuid
id = uuid.uuid4()
print(id)Python 3.14 added uuid.uuid7(). On older versions, use a compatibility package that implements RFC 9562.
import uuid
id = uuid.uuid7()
print(id)uuid.uuid7() is native starting in Python 3.14. Use a UUID compatibility library or keep using v4 until your deployment target reaches that version.These articles expand on related concepts, formats and practical considerations.