469,304 Members | 2,018 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,304 developers. It's quick & easy.

Help with super()

Why don't this code work?

import PRI

class Poscdnld_PYIO(PRI.BasicBatch):

def __init__(self, *argv):
super(Poscdnld_PYIO, self).__init__(*argv)

x = Poscdnld_PYIO()

I get this exception:
File "poscdnld_pyio.py", line 52, in __init__
super(Poscdnld_PYIO, self).__init__(*argv)
TypeError: super() argument 1 must be type, not classobj

What am I doing wrong? Thanks.

Jul 18 '05 #1
5 2159
Christopher J. Bottaro wrote:
Why don't this code work?

import PRI

class Poscdnld_PYIO(PRI.BasicBatch):

def __init__(self, *argv):
super(Poscdnld_PYIO, self).__init__(*argv)

x = Poscdnld_PYIO()

I get this exception:
File "poscdnld_pyio.py", line 52, in __init__
super(Poscdnld_PYIO, self).__init__(*argv)
TypeError: super() argument 1 must be type, not classobj

What am I doing wrong? Thanks.


super() does not work with classic classes:
class Classic: pass .... class A(Classic): .... def __init__(self):
.... super(A, self).__init__()
.... A() Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 3, in __init__
TypeError: super() argument 1 must be type, not classobj

whereas:
class A(object): .... def __init__(self):
.... super(A, self).__init__()
.... A()

<__main__.A object at 0x402ac02c>

Invoking

def __init__(self, *argv):
PRI.BasicBatch.__init__(self, *argv)

explicitly instead works as well unless you need cooperative methods which
are only possible with newstyle classes.

Peter

Jul 18 '05 #2
Christopher J. Bottaro wrote:
Why don't this code work?

import PRI

class Poscdnld_PYIO(PRI.BasicBatch):

def __init__(self, *argv):
super(Poscdnld_PYIO, self).__init__(*argv)

x = Poscdnld_PYIO()

I get this exception:
File "poscdnld_pyio.py", line 52, in __init__
super(Poscdnld_PYIO, self).__init__(*argv)
TypeError: super() argument 1 must be type, not classobj

What am I doing wrong? Thanks.


I don't know what PRI is, but I suspect that PRI.BasicBatch is a classic
class, not a new-style class. The super function only works for
new-style classes:
class C: .... def __init__(self):
.... super(C, self).__init__()
.... c = C() Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "<interactive input>", line 3, in __init__
TypeError: super() argument 1 must be type, not classobj class C(object): .... def __init__(self):
.... super(C, self).__init__()
.... c = C()

Jul 18 '05 #3
Steven Bethard schrieb:
Christopher J. Bottaro wrote:
Why don't this code work?

import PRI

class Poscdnld_PYIO(PRI.BasicBatch):
def __init__(self, *argv):
super(Poscdnld_PYIO, self).__init__(*argv)

x = Poscdnld_PYIO()

I get this exception:
File "poscdnld_pyio.py", line 52, in __init__
super(Poscdnld_PYIO, self).__init__(*argv)
TypeError: super() argument 1 must be type, not classobj

What am I doing wrong? Thanks.


I don't know what PRI is, but I suspect that PRI.BasicBatch is a classic
class, not a new-style class. The super function only works for
new-style classes:


Never heard of new-stype and classiv-class... What are the differences?

Thx,

Florian
Jul 18 '05 #4

Florian,

See: http://www.python.org/doc/newstyle.html

/arg
On Dec 7, 2004, at 5:38 AM, Florian Lindner wrote:
Steven Bethard schrieb:
Christopher J. Bottaro wrote:
Why don't this code work?

import PRI

class Poscdnld_PYIO(PRI.BasicBatch):
def __init__(self, *argv):
super(Poscdnld_PYIO, self).__init__(*argv)

x = Poscdnld_PYIO()

I get this exception:
File "poscdnld_pyio.py", line 52, in __init__
super(Poscdnld_PYIO, self).__init__(*argv)
TypeError: super() argument 1 must be type, not classobj

What am I doing wrong? Thanks.

I don't know what PRI is, but I suspect that PRI.BasicBatch is a
classic class, not a new-style class. The super function only works
for new-style classes:


Never heard of new-stype and classiv-class... What are the differences?

Thx,

Florian
--
http://mail.python.org/mailman/listinfo/python-list


Jul 18 '05 #5
Thank you everyone for the help, that cleared it up for me.

Andy Gross wrote:

Florian,

See: http://www.python.org/doc/newstyle.html

/arg
On Dec 7, 2004, at 5:38 AM, Florian Lindner wrote:
Steven Bethard schrieb:
Christopher J. Bottaro wrote:
Why don't this code work?

import PRI

class Poscdnld_PYIO(PRI.BasicBatch):
def __init__(self, *argv):
super(Poscdnld_PYIO, self).__init__(*argv)

x = Poscdnld_PYIO()

I get this exception:
File "poscdnld_pyio.py", line 52, in __init__
super(Poscdnld_PYIO, self).__init__(*argv)
TypeError: super() argument 1 must be type, not classobj

What am I doing wrong? Thanks.

I don't know what PRI is, but I suspect that PRI.BasicBatch is a
classic class, not a new-style class. The super function only works
for new-style classes:


Never heard of new-stype and classiv-class... What are the differences?

Thx,

Florian
--
http://mail.python.org/mailman/listinfo/python-list

Jul 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.