If it won't be simple, it simply won't be. [source code] by Miki Tebeka, CEO, 353Solutions

Sunday, June 25, 2006

Quick ID Generator

Sometimes I find myself in the need to assign unique id for objects, count from itertools is a quick solution.

from itertools import count

next_id = count(0).next

print next_id() # 0
print next_id() # 1
print next_id() # 2
Post a Comment

Blog Archive