[Python-Dev] Signature of function with default value uncapturable in Python and C
Vajrasky Kok
sky.kok at speaklikeaking.com
Thu Jan 16 03:25:01 CET 2014
More information about the Python-Dev mailing list
Thu Jan 16 03:25:01 CET 2014
- Previous message: [Python-Dev] Argument Clinic Derby update
- Next message: [Python-Dev] Signature of function with default value uncapturable in Python and C
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] Argument Clinic Derby update
- Next message: [Python-Dev] Signature of function with default value uncapturable in Python and C
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list