Kirby,

This is an interesting and subtle point.  I understand the distinction that you 
are making, but syntactically and pragmatically, the call to a class 
constructor IS a function call in Python (unlike languages such as Java where 
one needs "new" to call a constructor).  As support for this point of view, I 
would point to the Python documentation:

https://docs.python.org/3/library/functions.html

Both the section heading and the table in which "range" and "list" occur have 
the heading "Built-in Functions."  Yes, it says there are both built-in 
functions and types, but they are lumped together under this broader category. 
If I tell my students that "list is not a built-in function,"  I guarantee some 
smart aleck is going to pull up that table of built-in functions to "prove" me 
wrong.

This is an issue I thought about when writing the Python 3 version of my 
textbook. In the end, it seemed more awkward/muddying to pedantically separate 
the call to a constructor (invoked by the type name) vs. a call to a "normal" 
function. They look, feel, and act the same to the user. Just as I would 
consider any method invocation a "function call", I consider the constructor 
invocation to be a function call.

I concede your technical point, but I stand by my (and other authors') decision 
on how to treat this.

Cheers,

--John

John Zelle, PhD
Professor of Computer Science
Wartburg College

________________________________
From: Edu-sig [edu-sig-bounces+john.zelle=wartburg....@python.org] on behalf of 
kirby urner [kirby.ur...@gmail.com]
Sent: Saturday, January 23, 2016 11:03 AM
To: edu-sig@python.org
Subject: [Edu-sig] a common misconception


A common misconception in communicating Python is
that range() and even list() are "function calls".  That's
correct for range() in 2.x:

>>> type(range)
<type 'builtin_function_or_method'>

but has never been correct terminology regarding list().

Example:

"""
>From Chapter 9 of Inventing in Python:

The range() and list() Functions

When called with one argument, range() will return a range object of integers 
from 0 up to (but not including) the argument. This range object can be 
converted to the more familiar list data type with the list() function. Try 
entering list(range(10)) into the interactive shell:
"""

The author knows a range object is returned, however that's
our clue that range() is calling a type (a class) and returning
an instance of that class, ditto list( ).

I'd like to see the Python 3.x teaching literature not muddying
the waters by referring to range() and list() -- and zip() and
enumerate() -- as "function calls".

Kirby

_______________________________________________
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig

Reply via email to