Re: [python-nl] extending classes
On Thu, Apr 20, 2006 at 02:07:15AM +0200, Guido Wesdorp wrote: > Syntax is super(, ), voorbeeld: Dat dacht ik ook, maar ik krijg een error. > def test3(test): > def __init__(self): > super(test3, self).__init__() >>> class test5(test): ... def __init__(self): ... super(test5,self).__init__() ... print 'test5' ... >>> t = test5() Traceback (most recent call last): File "", line 1, in ? File "", line 3, in __init__ TypeError: super() argument 1 must be type, not classobj En wat nou het verschil tussen een type en een classobj is, geen idee. Dit gaat fout in python 2.3 en 2.4 Groet, Chris ___ Python-nl mailing list [email protected] http://mail.python.org/mailman/listinfo/python-nl
Re: [python-nl] extending classes
Chris Niekel wrote: > TypeError: super() argument 1 must be type, not classobj > Ah, er wordt niet van 'object' gesubclassed... >>> class test1(object): ... def __init__(self): ... pass ... >>> class test2(test1): ... def __init__(self): ... super(test2, self).__init__() ... >>> test2() <__main__.test2 object at 0xb7aa574c> 'super' werkt alleen bij 'new style classes', oftewel als je van 'object' subclassed (aan te raden, brengt een hoop fijnigheid). Cheers, Guido ___ Python-nl mailing list [email protected] http://mail.python.org/mailman/listinfo/python-nl
Re: [python-nl] extending classes
On 20-apr-2006, at 9:45, Chris Niekel wrote: > On Thu, Apr 20, 2006 at 02:07:15AM +0200, Guido Wesdorp wrote: >> Syntax is super(, ), voorbeeld: > > Dat dacht ik ook, maar ik krijg een error. > >> def test3(test): >> def __init__(self): >> super(test3, self).__init__() > class test5(test): > ... def __init__(self): > ... super(test5,self).__init__() > ... print 'test5' > ... t = test5() > Traceback (most recent call last): > File "", line 1, in ? > File "", line 3, in __init__ > TypeError: super() argument 1 must be type, not classobj > > En wat nou het verschil tussen een type en een classobj is, geen idee. > Dit gaat fout in python 2.3 en 2.4 Super werkt alleen als de klasse een new-style klasse is. Dat houdt in dit geval in dat test een subklasse van object moet zijn. Ronald ___ Python-nl mailing list [email protected] http://mail.python.org/mailman/listinfo/python-nl
Re: [python-nl] extending classes
Chris Niekel wrote: > TypeError: super() argument 1 must be type, not classobj > > En wat nou het verschil tussen een type en een classobj is, geen idee. > Dit gaat fout in python 2.3 en 2.4 De root classe van de inheritence boom moet object zijn: class test(object) Zie http://docs.python.org/lib/built-in-funcs.html#l2h-70: "super() only works for new-style classes." Martijn Pieters ___ Python-nl mailing list [email protected] http://mail.python.org/mailman/listinfo/python-nl
[python-nl] Job posting: Freelancer gezocht
Locatie: Amsterdam Voor een project met een meerjarige looptijd zijn wij op zoek naar een freelancer met de volgende skills: - Python (uiteraard) - Web applications - Javascript / DHTML - Relational databases - Object databases Een affiniteit met classificatie systemen en cultureel erfgoed is een pluspunt. Voor meer informatie neem contact op met: Etienne Posthumus Mnemosyne t: +31 20 616 1039 m: [EMAIL PROTECTED] ___ Python-nl mailing list [email protected] http://mail.python.org/mailman/listinfo/python-nl
