Aug-12-2018, 01:12 PM
In a python script, when you see the expression
Often, this value is a callable object, which means that it can be used in a call expression such as in
Typically, when 'spam' is a module and 'eggs' is a function defined in this module, the expression
spam.eggsit means that the object 'spam' has an attribute 'eggs'. The result of the expression is another object, the value of the attribute 'eggs' of the 'spam' object.
Often, this value is a callable object, which means that it can be used in a call expression such as in
spam.eggs(4)It may happen, but this is not necessarily the case, that 'eggs' is a method of the class of the object 'spam'. In that case, the value of
spam.eggs
is a special callable object named an instancemethod.Typically, when 'spam' is a module and 'eggs' is a function defined in this module, the expression
spam.eggs()
is an example of the same syntax, but eggs is not a method of the ModuleType. This illustrates the fact that this expression may have different semantics.