2015-07-03 11:54 GMT+02:00 Peter Otten <__peter__@web.de>:
Pierre Quentel wrote:

> With the proposed Range class, here is an implementation of the Fibonacci
> sequence, limited to 2000 :
>
> previous = 0
> def fibo(last):
>     global previous
>     _next, previous = previous+last, last
>     return _next
>
> print(list(Range(1, 2000, fibo)))

How would you make

print(list(Range(1000, 2000, fibo)))

work?

I wouldn't, the Fibonacci sequence starts with (0, 1), not with (0, 1000)
 
Without that and with the `previous` global under the rug that doesn't
look range-like.


_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/