DEV Community

Discussion on: How to Remove Dashes in UUID

Collapse
 
otumianempire profile image
Michael Otu

Hello, I hope it is okay to drop the snippet below. I saw that you were using a hex, from UUID. Basically, split at the dashes and join with empty string.

from uuid import uuid4


def remove_dashes(uid):
    return "".join(str(uid).split("-"))


sample_uid = uuid4()

sample_output = remove_dashes(sample_uid)

print(str(sample_uid), sample_output, sep="\n")
# 52af7d72-3b7c-4048-b3b9-28dff0c8308d
# 52af7d723b7c4048b3b928dff0c8308d
Enter fullscreen mode Exit fullscreen mode
Collapse
 
serhatteker profile image
Serhat Teker

Seems cool; vanilla python -w/o any lib.