[Edu-sig] a common misconception

kirby urner kirby.urner at gmail.com
Sat Jan 23 15:14:31 EST 2016

On Sat, Jan 23, 2016 at 11:58 AM, John Zelle <john.zelle at wartburg.edu>

> 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.

Great to hear from you John!

I've just started working at one PDX Code Guild in downtown Portland and
was pleased to find numerous copies of your book scattered about, clearly
one of the favorite resources of this tiny academy (connected to Portland
State and its "business accelerator / incubator" program).

You'll notice the documentation *does* draw attention to the distinction,
twixt function call and type call, when you go to list() or range() from
the table at the top at the web page you sight.

class list([iterable])
> Rather than being a function, list is actually a mutable sequence type, as
> documented in Lists and Sequence Types — list, tuple, range.
> range(start, stop[, step])
> Rather than being a function, range is actually an immutable sequence
> type, as documented in Ranges and Sequence Types — list, tuple, range.

I think I'd make the distinction between "formal" or "High Church" Python
(yes, there's a slight mocking Monty Pythonic spin) versus The Vernacular
(or even "vulgar") Python.  When teaching, we can treat these as modes e.g.

"Just to get High Church about it, range( ) is not a function call but a
call to a type:  not all callables are functions, even though all functions
are callables."

pow( ) and sqrt( ) and like that are true functions, as indicated by
feeding them to type( ).

I want the output to type( ) to make sense to students.  I want a lot of
"type awareness" i.e. every object has a type.

In explaining the transition from Python 2.x to 3.x I like to say "some of
what used to be functions, like zip, became types in their own right".

For contrast:

Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:32:06)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> type(range)
<type 'builtin_function_or_method'>
>>> type(zip)
<type 'builtin_function_or_method'>


Python 3.2.3 (v3.2.3:3d0686d90f55, Apr 10 2012, 11:09:56)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> type(range)
<class 'type'>
>>> type(zip)
<class 'type'>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20160123/d36535e8/attachment.html>

More information about the Edu-sig mailing list