PyEuler
Arnaud Delobelle
arnodel at googlemail.com
Mon Feb 25 18:01:56 EST 2008
On Feb 25, 10:52 pm, bearophileH... at lycos.com wrote:
> Arnaud Delobelle:
>
> > In this case why not:
>
> > def xfib(a=1, b=1):
> > while True:
> > yield a
> > a += b
> > yield b
> > b += a
>
> That's a bit less easy to understand than my version, for me.
> In my version is easy to see the values of the variables.
I disagree; the generator function has no right to keep a and b to
itself. a and b cry out to be function parameters. The user may want
to start a fibonacci sequence with any two initial values. IMHO one
of the great qualities of Python is that it makes this very easy in
most cases.
> And using a
> longer function name is better.
Up to a certain length :-)
--
Arnaud
More information about the Python-list
mailing list