use of super()

John Arbash Meinel john at arbash-meinel.com
Thu Jan 5 03:10:38 GMT 2006


Robert Collins wrote:
> I just ran into the following:
> 
>     def setUp(self):
>         super(self.__class__, self).setUp()
> 
> This does not work - it results in the wrong code when further
> subclassing occurs.
> 
> super must always be 'super(THECURRENTCLSASNAME, self).method()'
> 
> Rob

Where was that done?
I actually thought we couldn't use super() in test classes, because the
base level TestCase is not a child of object. and super() is only
defined for new-style python classes.

Otherwise I'm curious why self.__class__ wouldn't work, it seems like it
would be a cute way to get the right class. (Though if it really worked,
then I would have thought the interface would be the even nicer
super(self).setUp())

John
=:->

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060104/4ba58d66/attachment.pgp 


More information about the bazaar mailing list