[Python-ideas] Pass a function as the argument "step" of range()

Pierre Quentel pierre.quentel at gmail.com
Fri Jul 3 08:07:20 CEST 2015


2015-07-03 0:01 GMT+02:00 Terry Reedy <tjreedy at udel.edu>:

> On 7/2/2015 4:20 PM, Pierre Quentel wrote:
>
>>
>> I agree that this is a blocking issue : as far as I know all Python
>> built-in functions return objects of a given type, regardless of its
>> arguments.
>>
>
> That is generally true.  But classes always return instances of the class
> when called, and range is a class, not a function.


>>> range
<class 'range'>
>>> class A(range):pass
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: type 'range' is not an acceptable base type
>>>

So yes, range is a class, but a strange one


>
>
> --
> Terry Jan Reedy
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150703/282ffa95/attachment.html>


More information about the Python-ideas mailing list