The uuid4() function of Python\'s module uuid generates a random UUID, and seems to generate a different one every time:
In [1]: import uuid
In
Since the straight-forward solution hasn't been posted yet to generate consistent version 4 UUIDs:
import random
import uuid
rnd = random.Random()
rnd.seed(123)
uuid = uuid.UUID(int=rnd.getrandbits(128), version=4)
where you can see then:
>>> uuid.version
4
This doesn't just "mock" the version information. It creates a proper UUIDv4:
The version argument is optional; if given, the resulting UUID will have its variant and version number set according to RFC 4122, overriding bits in the given hex, bytes, bytes_le, fields, or int.
Python 3.8 docs