getting tut. example to work
John Forse
johnforse at talktalk.net
Mon Feb 23 22:31:56 EST 2009
I'm trying some examples from the language ref sections on the site in
the process of learning some python in 3.0.1. I've tried to run both
of the samples below ,but the only printout is "generator object chain
at 0x11f4dc8" whether I use print() or not . How do I use the sample
to produce the expected printout a b c d e f.
Thanks
John F
A
def chain(*iterables):
for it in iterables:
for element in it:
print(element)
yield element
def main():
chain('abc','def')
main()
B
alternative
import itertools
itertools.chain('abc','def')
More information about the Python-list
mailing list