[IronPython] Problem with super
Christian Muirhead
christian.muirhead at resolversystems.com
Thu Jul 12 03:35:33 PDT 2007
Anders M. Mikkelsen wrote:
> I have some problems getting 'super' working with IronPython.
> Running the following simple script:
>
> class A:
> def Foo(self):
> pass
>
> class B(A):
> def Foo(self):
> super(B, self).Foo()
>
> B().Foo()
> yields:
>
> TypeError: expected type, got classobj
>
> Any ideas?
Super only works for new-style classes - if you change class A to
inherit from object super will work correctly.
Classes with no superclass list are created as old-style classes, which
have slightly different semantics.
In general, all new classes you create should inherit from object, or
some other built-in type, so that super, property and __metaclasss__
will work correctly for them. Old-style classes are only really kept for
backwards compatibility, and I think they're going away at some version
in the future - at which point "class A:" will define a normal new-style
class.
Cheers,
Christian
--
Christian Muirhead
Resolver Systems
christian.muirhead at resolversystems.com
Office address: 17a Clerkenwell Road, London EC1M 5RD, UK
Registered address: 843 Finchley Road, London NW11 8NA, UK
Resolver Systems Limited is registered in England and Wales as company
number 5467329.
VAT No. GB 893 5643 79
More information about the users
mailing list