This question already has an answer here:
I came upon this reading the python documentation on the
If the second argument is omitted, the super object returned is unbound. If the second argument is an object, isinstance(obj, type) must be true. If the second argument is a type, issubclass(type2, type) must be true (this is useful for classmethods).
Can someone please give me an example of a distinction between passing a Type as a second argument versus passing an Object?
Is the documentation talking about an instance of an object?
This should give you some perspective: cafepy.com/article/python_types_and_objects/…
karthikr Agreed, great article
Or have a look at this question stackoverflow.com/questions/100003/… and the great answer , whilst its about metaclasses it details types and objects to build up the description of a metaclass - really good read.
Such an awesome question. I've been trying teach my self OOP in Python (my only language), grappling with using inheritance and calling superclass methods. I read that explanation about super had the same question.
Is super a way to help with Memoization of function calls? I have an object that speeds up calls to another interpreter by checking for the functions existence and then assigning an attribute on the object with an object that directly calls the function. So I basically only lookup the function once and memoize it to a callable attribute. I have to use object.__setattr__(self, "attribute", callableObj) in order to keep it from looping/calling my redefinition of "settr". Does super do the same thing?
Demolishun: Um, no. You use super to get at inherited versions of overridden methods. Check out the docs
Okay, so it is similar, but it allows for dynamic reference of the base class, but not by name. That is one use case. rhettinger.wordpress.com/2011/05/26/super-considered-super Thanks for the ref.
I beg to differ w.r.t., it is not limited to builtins. Everyone can and does define their own types.
smitkpatel, I think you may be thinking about "builtin" types.
builtin - default potato - potato