Created
July 8, 2019 19:43
-
-
Save eyaltrabelsi/bcd548f3c8e5062efedf802e49e2800e to your computer and use it in GitHub Desktop.
Python trick generating unique ids
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This creates a randomized 128-bit number that will almost certainly be unique. | |
# In fact, there are over 2¹²² possible UUIDs that can be generated. That’s over five undecillion (or 5,000,000,000,000,000,000,000,000,000,000,000,000). | |
>>> import uuid | |
>>> user_id = uuid.uuid4() | |
>>> user_id | |
UUID('7c2faedd-805a-478e-bd6a-7b26210425c7') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment