Python Forum

Full Version: How to make a function for auto generated id
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi Guys,
Could you please help me out about how we can make a function in Python which can generate auto numeric id whenever calling that function?

Thnaks
Please be a bit more specific
https://docs.python.org/3/library/uuid.html Wrote:This module provides immutable UUID objects (the UUID class) and the functions uuid1(), uuid3(), uuid4(), uuid5() for generating version 1, 3, 4, and 5 UUIDs as specified in RFC 4122.

If all you want is a unique ID, you should probably call uuid1() or uuid4(). Note that uuid1() may compromise privacy since it creates a UUID containing the computer’s network address. uuid4() creates a random UUID.

Depending on support from the underlying platform, uuid1() may or may not return a “safe” UUID. A safe UUID is one which is generated using synchronization methods that ensure no two processes can obtain the same UUID. All instances of UUID have an is_safe attribute which relays any information about the UUID’s safety, using this enumeration: