A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2014-January/131664.html below:

[Python-Dev] Signature of function with default value uncapturable in Python and C

[Python-Dev] Signature of function with default value uncapturable in Python and CVajrasky Kok sky.kok at speaklikeaking.com
Thu Jan 16 03:25:01 CET 2014
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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4