Chapter 2. Branching Using Dictionaries
Functions are objects like everything else in Python, and a function’s name is an object reference that refers to the function. If we write a function’s name without parentheses, Python knows we mean the object reference, and we can pass such object references around just like any others. We can use this fact to replace if statements that have lots of elif clauses with a single function call.
In the examples accompanying the book, Programming in Python 3: A Complete Introduction to the Python Language,[*] is an interactive console program called dvds-dbm.py, that has the following menu:
[*] All the examples are available for download from www.qtrac.eu/py3book.html.
(A)dd (E)dit (L)ist (R)emove (I)mport e(X)port (Q)uit ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access