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. 5 2363
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
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()
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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |