Help with super()

  • Thread starter Christopher J. Bottaro
  • Start date
C

Christopher J. Bottaro

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.
 
P

Peter Otten

Christopher said:
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:
.... def __init__(self):
.... super(A, self).__init__()
....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:
.... def __init__(self):
.... super(A, self).__init__()
....<__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
 
S

Steven Bethard

Christopher said:
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:
.... def __init__(self):
.... super(C, self).__init__()
....Traceback (most recent call last):
File "<interactive input>", line 1, in ?
.... def __init__(self):
.... super(C, self).__init__()
....
 
F

Florian Lindner

Steven said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top