[Tutor] Generating unique ID

Wayne srilyk at gmail.com
Wed Oct 28 20:07:08 CET 2009

On Wed, Oct 28, 2009 at 1:52 PM, Timo List <timomlists at gmail.com> wrote:

> Hello,
> I'm writing an application which will hold a database of people. Ofcourse,
> people can have the same name, so I want to stock them with an unique ID.
> I've searched and found some things:
> - uuid.uuid4()
> - id(name)
> - os.urandom(n)
> But they seem overkill to me. Well, maybe not id().
> What should I use the best for this? Maybe examples of other programs that
> do something alike?

You could use SQLite... I believe it supports autoincrement. If you just
want a random number, you can use the random library.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091028/8d8b391f/attachment.htm>

More information about the Tutor mailing list