What is the purpose of the second argument to super()?
I've always found the docs to be fairly confusing. They didn't give me enough context to tell what was going on. I also find the terminology confusing: "type" seems to mean "new style class object", and "object" seems to mean "instance."
What happens with the second operand is a bit of sleight of hand. The object returned from super() gives you access to the methods on the next level up the mro, however when you use it to invoke a method, then the 'self' passed to that method is the second object, not the instance returned from super().
In most cases, this is exactly what you want, since if the superclass method makes any changes to the instance, you want to be able to see them after the call completes.
What is meant by the returning of an 'unbound' object when the argument is omitted.
This is basically for calling static methods. Since a static method is not passed an instance, you need a version of the object returned from super() that doesn't bind the method to an instance.
There is also the possibility that you might really want to call an instance or class method as an unbound method, explicitly passing it the instance. This is the reason that the object returned from super() can't make the distinction automatically by simply checking for a static method.
Also, when would I pass an object as the second argument, and when would I pass a type?
You need to pass the class object when you're calling a class method. While __new__ is technically a static method, for most practical purposes you can regard it as a class method.
John Roth
Thanks,
Tobiah
-- http://mail.python.org/mailman/listinfo/python-list