[Tutor] 2.7.3 generator objects
crawlzone at gmail.com
Sun Sep 2 07:44:48 CEST 2012
I was playing with os.walk today. I can use os.walk in a for loop (does
that make it an iterator or just an irritable? ^_^), but if I assign
os.walk to 'test' (test = os.walk(<path>)), that variable becomes a
generator object that does not work in a for loop. From what I can tell,
it's supposed to work in a generator function using 'yield', but I'm at
a loss at how that all works.
I suppose I should just stick with using the os.walk in the for loop,
but I'd like to make sense of the whole thing. Please someone explain
this to me?
More information about the Tutor