[Edu-sig] What's a Callable?

kirby urner kirby.urner at gmail.com
Thu Mar 27 21:12:01 CET 2014


What's a callable?

In making the transition from Algebra to a computer science
friendly math class, such as many states have legislatively
enabled (Oregon one such state), the distinction between
"what's a callable" and "what's not" may feel familiar.

Traditional math notation has to disambiguate between b * x,
bx, b(x) and (b)(x), i.e. no operator at all between operands
is taken to mean "multiplication".  Few computer languages
try to take it that far, but in reading (b)(x) it still helps to know
if b is a "callable" or not, as if it is, then b(x) may be the
evaluation strategy to employ.

>>> def F(x): return x
>>> (F)(3)
3

What I like about "callable" is one can identify a callable as
having "a mouth" i.e. the parens form an emoticon-style
sideways mouth, and that's the hallmark of any callable,
whether they "eat arguments" or just "suck air".  call_me().

Students know about emoticons, little sideways faces, so
to associate "callable" with "emoticon" is anchoring and
reinforcing.  Then when you see the typically amateur
use of parens:

def F(x):
    return(2 + x)

you can say:  remember, return-the-keyword is not a
callable; it has no mouth.  return(2 + x) is not illegal
but that's not a picture of return eating, that's a picture
of  (2 + x) putting on a belt or fencing itself in. 'return'
does not eat, nor 'if', nor 'while'.

Kirby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20140327/6eceb62c/attachment.html>


More information about the Edu-sig mailing list