Skip to content

Instantly share code, notes, and snippets.

@eyaltrabelsi
Created July 8, 2019 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eyaltrabelsi/bcd548f3c8e5062efedf802e49e2800e to your computer and use it in GitHub Desktop.
Save eyaltrabelsi/bcd548f3c8e5062efedf802e49e2800e to your computer and use it in GitHub Desktop.
Python trick generating unique ids
# 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