Skip to content

Instantly share code, notes, and snippets.

@sujith3g
Last active September 24, 2019 09:09
Show Gist options
  • Save sujith3g/059052243bbff5893479e2b0db59c274 to your computer and use it in GitHub Desktop.
Save sujith3g/059052243bbff5893479e2b0db59c274 to your computer and use it in GitHub Desktop.
Generate a Meteor-style object ID from python for use in MongoDB
def genMeteorID(length=17):
UNMISTAKABLE_CHARS = "23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz"
randomString = ""
for i in range(length):
randomString += random.choice(UNMISTAKABLE_CHARS)
return randomString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment