May 2017
Intermediate to advanced
310 pages
8h 5m
English
In Python, it is not only data types that are treated as objects. Both functions and classes are what are known as first class objects, allowing them to be manipulated in the same ways as built-in data types. By definition, first class objects are:
In Python, the term first class object is a bit of a misnomer since it implies some sort of hierarchy, whereas all Python objects are essentially first class.
To have a look at how this works, let's define a simple function:
def greeting(language): if language== 'eng': return 'hello world' if language == 'fr' return 'Bonjour ...