list(), tuple() should not place at "Built-in functions" in documentation

Stefan Behnel stefan_ml at
Wed Jul 20 02:21:34 EDT 2011

Terry Reedy, 19.07.2011 18:31:
> Chapter 5 is mostly about the behavior of built-in class instances. For
> some classes, like range, instances only come from class calls and the
> behavior of instances is intimately tied to the constructor arguments.
> Having the constructor described in C.5 might be useful.

I strongly disagree. To me, range() being implemented as a class or 
function is a clear implementation detail that is of no importance to 
virtually all use cases. It's only ever used as a function that returns a 
list (in Py2) or something iterable (in Py3). Whether that "iterable" is of 
type "range" or not is irrelevant. Even in Py2, it could return a subtype 
of list, and would still fulfil its interface.

So, IMO, it makes no sense to have range() described in the builtin types 
section. It would rather be confusing. It's perfectly correct and 
sufficient to describe it in the builtin functions section.

Remember that Python is duck-typed. It makes no difference if you call a 
function that returns a new instance of a type, or the type itself to 
return an instance of itself (or something completely different, if it 
wants to).

The distinction between types and functions is blurred in Python, and 
that's a good thing. Just look at the itertools module. Some of the 
"functions" are implemented as functions, some are implemented as types, 
and some are functions that delegate to a type. But they all have the same 
interface, which makes them easy to understand as a whole and which keeps 
the implementation details out of the way.


More information about the Python-list mailing list