To Joel's and Wesley's valuable comments I add:
Calling a generator function returns a /generator object/.
>>> def x(n):
... for i in range(n): yield i
...
>>> y = x(3)
>>> print y
A generator object can be used instead of some other "iterable" (e.g.)
in for statements.
>>> for i in y:print
> On Tue, Apr 3, 2012 at 2:38 PM, mike jackson wrote:
> I am trying understand python and have done fairly well, So for it has been
> easy to learn and is concise. However I seem to not quite understand the use
> of a generator over a function(I am familiar with functions [other languages
> an
On Tue, Apr 3, 2012 at 2:38 PM, mike jackson wrote:
> I am trying understand python and have done fairly well, So for it has been
> easy to learn and is concise. However I seem to not quite understand the use
> of a generator over a function(I am familiar with functions [other languages
> and
Hey Mike
The following link should help you. http://www.dabeaz.com/generators/
. Cool slide deck with examples from David Beazley's explanation of
generators.
-A
On Tue, Apr 3, 2012 at 11:38 AM, mike jackson wrote:
> I am trying understand python and have done fairly well, So for it has be
I am trying understand python and have done fairly well, So for it has been
easy to learn and is concise. However I seem to not quite understand the use
of a generator over a function(I am familiar with functions [other languages
and math]). To me (excepting obvious syntax differences) a gener
On Tuesday 24 July 2007 13:11, Kent Johnson wrote:
> 'while 1' is optimized to just a jump - the compiler recognizes that the
> test is not needed and skips it. 'while True' requires looking up the
> value of the name 'True' and testing it.
This may seem counter intuitive, but the reason for this
Tiger12506 wrote:
>> I am new to Python but not new to programming languages. I have seen this
>> "while 1" a lot. In fact in other languages I would expect "while 1" to
>> be
>> the same as "while TRUE".
The predefined constants True and False were not added to Python until
version 2.3. Befor
Tiger12506 wrote:
>> I am new to Python but not new to programming languages. I have seen this
>> "while 1" a lot. In fact in other languages I would expect "while 1" to
>> be
>> the same as "while TRUE". I have used that in other languages, but in the
>> definition below I would expect the "yi
> I am new to Python but not new to programming languages. I have seen this
> "while 1" a lot. In fact in other languages I would expect "while 1" to
> be
> the same as "while TRUE". I have used that in other languages, but in the
> definition below I would expect the "yield b..." to continue o
> Please forgive my instrusion with some simple questions. I don't have any
> formal training in programming so I have to get some guidance to some
> terminology from time to time. What is a generator and what is its
> purpose?
Think of a generator as a list whose contents haven't been finished
Doug Glenn wrote:
> Greetings all,
>
> Please forgive my instrusion with some simple questions. I don't have
> any formal training in programming so I have to get some guidance to
> some terminology from time to time. What is a generator and what is its
> purpose?
If you are that new to prog
Greetings all,
Please forgive my instrusion with some simple questions. I don't have any
formal training in programming so I have to get some guidance to some
terminology from time to time. What is a generator and what is its purpose?
I am planning on building a DVD catalog utility for Linux i
12 matches
Mail list logo