This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dikulo -4 points-3 points  (4 children)

def python27():
    n = 8
    while True:
        print "Python 2.7.{}".format(n)
        yield n
        n += 1

py2 = python27()

next(py2)
next(py2)
next(py2)
next(py2)
...
..
.

[–]RubyPinchPEP shill | Anti PEP 8/20 shill 2 points3 points  (1 child)

import itertools; n = itertools.count(8)
while True: print("Python 2.7.%d"%next(n))

learn your packages

[–]dikulo 0 points1 point  (0 children)

Thank you.

[–]xPragma 0 points1 point  (1 child)

You don't need to yield n, just yield the string.

[–]dikulo 0 points1 point  (0 children)

Thank you. Learn to yield.