ADVANCED FUNCTION CALLING
Beyond the basics of functions that we have already seen, Python also supports some more advanced function handling. The apply statement is a required feature if you want to be able to dynamically call a function without knowing its name or the arguments you will supply it beforehand. The map statement provides the same functionality as the Perl map function – it allows you to apply the same function to an arbitrary list.
The last two features are connected. It should come as no surprise that functions are just Python objects. As such, we can assign functions to names and then call them dynamically and therefore indirectly. As an extension of this, we can also create a name that points to a function that has no real ...
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