Mercurial > public > think_complexity
view ch2ex7.py @ 44:362d4ec7e794
Got a first draft Turing Machine working for chapter 6,
exercise 4. Next I have to figure out how to draw it
with a TMDrawer class.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 16 Jan 2013 21:44:02 -0600 |
parents | aea27d10dd18 |
children |
line wrap: on
line source
"""Chapter 2.7, exercise 7. Write a generator that yields an infinite sequence of alpha-numeric identifiers, starting with a1 through z1, then a2 through z2, and so on. """ import string def generate_identifier(): num = 1 while True: for c in string.lowercase: yield c + str(num) num += 1 if __name__ == '__main__': try: for name in generate_identifier(): print name except KeyboardInterrupt: print "Control-C interrupt"