Generating a unique identifier

Steven D'Aprano steve at
Sat Sep 8 05:24:54 CEST 2007

On Fri, 07 Sep 2007 19:17:44 -0700, Paul Rubin wrote:

>> Here's something which is a little less predictable than a straight
>> counter:
> It's still very easy to generate valid id's from that, or guess the next
> one with non-negligible probability.

Well, in my specific application, the only consequences of guessing a 
valid id is that you get to congratulate yourself for guessing a valid 
id :)

As it turned out, I decided that since the only reason I had for avoiding 
consecutive ids was that they didn't look random, and that this would not 
really matter because no human being (including myself) was actually 
going to be looking at them except during debugging, I used the 
intertools.count() solution.

Thanks to all who replied.


More information about the Python-list mailing list