Skip to content

Instantly share code, notes, and snippets.

@Mariatta
Created October 9, 2025 16:20
Show Gist options
  • Select an option

  • Save Mariatta/b53a30c8d41a43add0e491ffc66f897b to your computer and use it in GitHub Desktop.

Select an option

Save Mariatta/b53a30c8d41a43add0e491ffc66f897b to your computer and use it in GitHub Desktop.
Convert a string into a uuid-format
# Example script for converting from 'e032ef8ab56d4ee18b388973a5cfc766' into 'e032ef8a-b56d-4ee1-8b38-8973a5cfc766'
import uuid
def convert_to_uuid(input):
"""Convert the input into uuid format."""
return str(uuid.UUID(input))
input_str("e032ef8ab56d4ee18b388973a5cfc766")
output = convert_to_uuid(input_str)
print(output)
# example call
# >>> convert_to_uuid("e032ef8ab56d4ee18b388973a5cfc766")
# 'e032ef8a-b56d-4ee1-8b38-8973a5cfc766'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment