473,382 Members | 1,651 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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 2362
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: David Hirschfield | last post by:
I'm having trouble with the new descriptor-based mechanisms like super() and property() stemming, most likely, from my lack of knowledge about how they work. Here's an example that's giving me...
5
by: Stephen3776 | last post by:
I am doing an inventory control progam and trying to output a multiple array, I am getting an illegal conversion error java.lang.double !d. Can somebody tell me what I am doing wrong or if there is...
2
by: pinkf24 | last post by:
I cannot figure out how to add the following: Modify the Inventory Program to include an Add button, a Delete button, and a Modify button on the GUI. These buttons should allow the user to perform...
1
by: eshortt84 | last post by:
hey, i'm new to java and i keep getting the return type required error on this line; public dvds(int productNum, String name, int units, double price, String rating) { The code for the whole...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.