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

Get Perl To Python Migration now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.