On this page
uuid.uuid4
Prev: uuid.uuid3 | Up: uuid | Next: uuid.uuid5
Rel: uuid.bytes_, uuid.Enum, uuid.getnode, uuid.int_
Ref: docs.python.org — uuid.uuid4
Tags: #public #python3 #stdlib #uuid
Import
import uuid
from uuid import uuid4
Signature & Overview
uuid.uuid4()
Generate a random UUID.
Usage
import uuid
u = uuid.uuid4()
assert u.version == 4 and len(str(u)) == 36
Gotchas
- Default choice for unique IDs: Uses
os.urandom()(122 random bits).
REPL Inspect
from uuid import uuid4
help(uuid4)
Linked from
Related notes
- tuts/python3/stdlib_module/uuid/uuid3 Linked here; links to this page; shared tags: #stdlib, #uuid
- tuts/python3/stdlib_module/uuid/uuid5 Linked here; links to this page; shared tags: #stdlib, #uuid
- tuts/python3/stdlib_module/uuid/bytes_ Linked here; shared tags: #stdlib, #uuid
- tuts/python3/stdlib_module/uuid/Enum Linked here; shared tags: #stdlib, #uuid
- tuts/python3/stdlib_module/uuid/getnode Linked here; shared tags: #stdlib, #uuid
- tuts/python3/stdlib_module/uuid/int_ Linked here; shared tags: #stdlib, #uuid
- tuts/python3/stdlib_module/uuid/UUID Linked here; shared tags: #stdlib, #uuid
- tuts/python3/stdlib_module/uuid links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/uuid/main shared tags: #stdlib, #uuid
- tuts/python3/stdlib_module/uuid/SafeUUID shared tags: #stdlib, #uuid