On 02/09/12 06:44, Ray Jones wrote:
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.
On 09/01/2012 11:39 PM, Alan Gauld wrote:
On 02/09/12 06:44, Ray Jones wrote:
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
On Sun, Sep 2, 2012 at 1:44 AM, Ray Jones crawlz...@gmail.com wrote:
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? ^_^),
The output from os.walk is a generator, which is an iterator. os.walk
actually calls itself
On 09/01/2012 11:57 PM, eryksun wrote:
To be an iterable in general, it suffices to have either an __iter__
method or a __getitem__ method. Here are the glossary definitions:
http://docs.python.org/glossary.html#term-iterable
http://docs.python.org/glossary.html#term-iterator
After a few
On Sun, Sep 2, 2012 at 3:09 AM, Ray Jones crawlz...@gmail.com wrote:
But didn't I read somewhere that you can reset an iterator to go through
the whole process again?
You could implement that ability in your own objects, but it's not
part of the protocol.
I forgot to mention generator
On 02/09/12 17:09, Ray Jones wrote:
But didn't I read somewhere that you can reset an iterator to go through
the whole process again?
In general, no.
The usual way to reset an iterator is to re-create it.
walker = os.walk(/home/steve/start)
# ... process files in walker
walker =
Steven D'Aprano wrote:
On 02/09/12 17:09, Ray Jones wrote:
But didn't I read somewhere that you can reset an iterator to go through
the whole process again?
In general, no.
The usual way to reset an iterator is to re-create it.
walker = os.walk(/home/steve/start)
# ... process
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