According to http://docs.python.org/2/library/functions.html#super,
If the second argument is omitted, the super object returned is unbound.
Which is super(type).
I am wondering what is unbounded and when is it bounded.
To explain terms bound / unbound I will use functions, and — to be brief — I give up details and caveats.
There are 2 views:
Free function (unbound), for example the built-in function sum()
:
sum([1, 2, 3]) # 6
A function bound to an object (other name: object method) means that a user have to bind it to a particular object with the dot (.
) notation.
For example the use of built-in .upper()
method:
"Alice".upper() # ALICE
"Jacob".upper() # JACOB (the same method; different object, different result)
A function bound to a class (other name: class method) means that a user have to bind it to a particular class — again with the same dot (.
) notation.
Examples:
A.some_class_method() # A is a class
B.some_class_method(parameters) # B is a class
From the designer point of view there are the same 3 sorts of functions, so I use the same numbers for them:
A free (unbound) function is defined out of a class:
def free_function(parameters):
...
A function bound to an object is defined inside a class, with the first parameter reserved for an object and named self
(this name is only a convention, but a very strong one):
class A:
def bound_to_object(self, other_parameters):
...
A function bound to a class is defined inside a class, with the first parameter reserved for a class and named cls
(this name is only a convention, too, but a very strong one) and with the @classmethod
decorator just before it:
class A:
@classmethod
def bound_to_class(cls, other_parameters):
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With