Profile

Click to view full profile
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time. Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more...

Sunday, June 17, 2012

Create Universal Unique Identifier (UUID) in Python

Most of the time when I write database related programs, I often think about how to create a good id because one of the good id characteristic is meaningless. It should has no meaning, to doesn't let anyone understand something behind this id.

In Python, we can easily create it by using uuid module that is included in Python standard library as following example:
import uuid
ob = uuid.uuid4()
print str(ob)
There are 4 kinds of uuids in Python: uuid1(), uuid3(), uuid4(), and uuid5() that you can take a look for more details at http://docs.python.org/library/uuid.html.

2 comments:

  1. Thanks. Easy straight-forward example.

    ReplyDelete
    Replies
    1. Thank you for your comment ^^. Personally, I really like to write a short post and easy to follow.

      Delete