from itertools import count
next_id = count(0).next
print next_id() # 0
print next_id() # 1
print next_id() # 2
If it won't be simple, it simply won't be. [Hire me, 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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment