Re: My Generator Paradox!

2006-03-17 Thread vbgunz
I believe I understand now. the yield keyword is sort of like a cousin to return. return will bring back an object I can work with and so does yield *but* yield's object will most likely support the .next() method. So, if I worked with a function that ends with the return keyword and it returns a

Re: My Generator Paradox!

2006-03-17 Thread Robert Kern
vbgunz wrote: I believe I understand now. the yield keyword is sort of like a cousin to return. return will bring back an object I can work with and so does yield *but* yield's object will most likely support the .next() method. No, that's not really how it works. When a generator function is

Re: My Generator Paradox!

2006-03-17 Thread Ron Adam
Robert Kern wrote: vbgunz wrote: I believe I understand now. the yield keyword is sort of like a cousin to return. return will bring back an object I can work with and so does yield *but* yield's object will most likely support the .next() method. No, that's not really how it works. When a

Re: My Generator Paradox!

2006-03-17 Thread vbgunz
OK. I hope my understanding of the yield keyword and generators in a general sense are now better understood. When a generator function is assigned to an identifier, no code is executed and a generator is immediately returned. When the next() method is called on the new generator, code from top to

Re: My Generator Paradox!

2006-03-17 Thread Ron Adam
vbgunz wrote: OK. I hope my understanding of the yield keyword and generators in a general sense are now better understood. When a generator function is assigned to an identifier, no code is executed and a generator is immediately returned. When the next() method is called on the new

My Generator Paradox!

2006-03-16 Thread vbgunz
I am afraid that this is the first time in which I would probably need something explained to me as if I were a little child. I am having a hard time getting this through my thick skull. What in the world is wrong with this!? ''' ### '''

Re: My Generator Paradox!

2006-03-16 Thread Felipe Almeida Lessa
Em Qui, 2006-03-16 às 16:17 -0800, vbgunz escreveu: print generatorFunction() # generator object at 0xb723022c print generatorFunction().next()# item1 print generatorFunction().next()# item1 print generatorFunction().next()# item1 Each time you say generatorFunction(),

Re: My Generator Paradox!

2006-03-16 Thread Michal Kwiatkowski
vbgunz wrote: def generatorFunction(sequence=['item1', 'item2', 'item3']): for item in sequence: yield item yieldedValue = generatorFunction() You're creating an iterator here and binding it to name yieldedValue (which is bogus, it should be named valueGenerator or sth like

Re: My Generator Paradox!

2006-03-16 Thread David Wahler
vbgunz wrote: I am afraid that this is the first time in which I would probably need something explained to me as if I were a little child. I am having a hard time getting this through my thick skull. What in the world is wrong with this!? '''

Re: My Generator Paradox!

2006-03-16 Thread Schüle Daniel
it's easy to explain class X: pass x=X() y=X() x and y are different instances one can put in x x.item = 1 y doesn't even have an attribute item for example similar with generators they are *different* objects of same kind generator def fib(): ... a,b = 1,1 ... while True:

Re: My Generator Paradox!

2006-03-16 Thread [EMAIL PROTECTED]
vbgunz wrote: I am afraid that this is the first time in which I would probably need something explained to me as if I were a little child. I am having a hard time getting this through my thick skull. What in the world is wrong with this!? '''

Re: My Generator Paradox!

2006-03-16 Thread Fredrik Lundh
vbgunz wrote: I am afraid that this is the first time in which I would probably need something explained to me as if I were a little child. I am having a hard time getting this through my thick skull. What in the world is wrong with this!? '''