Dear friends,

>>> from itertools import repeat
>>> list(repeat('a', 3))
['a', 'a', 'a']
>>> list(repeat('a', 0))
[]
>>> repeat.__doc__
'repeat(object [,times]) -> create an iterator which returns the
object\nfor the specified number of times.  If not specified, returns
the object\nendlessly.'

If you omit the times argument:

>>> list(repeat('a'))
... unlimited of a .... sometimes it can hang your machine ....

In the C code it self, the default value of variable handling times
argument is -1. It checks how many arguments you give to the function.
So if you give -1 directly:

>>> list(repeat('a', -1))
[]

Negative value of times argument means 0.

So what is the correct signature of this function? The value is not
really capturable in Python and C.

repeat(object [,times = unlimited]) ????

Can we do this in Clinic? If not, should we?

Vajrasky
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to