I am trying to call a parent's __init__ method from the child's:
class ArbitraryBlock( InnerBlock):
def __init__(self, codelist, noout=False, **kwargs):
InnerBlock.__in it__(self, codelist, noout=noout, **kwargs)
I get this error:
<type 'exceptions.Typ eError'>: unbound method __init__() must be
called with InnerBlock instance as first argument (got ArbitraryBlock
instance instead)
I found a thread that talked about the parent and child being
different types, so I tried setting up the parent class 3 different
ways:
class InnerBlock:
class InnerBlock(obje ct):
class InnerBlock(empt y_class):
where
class empty_class(obj ect):
def __init__(self,_ d={},**kwargs):
kwargs.update(_ d)
self.__dict__=k wargs
I still get the same error. Why doesn't this work?
Thanks,
Ryan 1 2510
Ryan Krauss wrote:
I am trying to call a parent's __init__ method from the child's:
class ArbitraryBlock( InnerBlock):
def __init__(self, codelist, noout=False, **kwargs):
InnerBlock.__in it__(self, codelist, noout=noout, **kwargs)
I get this error:
<type 'exceptions.Typ eError'>: unbound method __init__() must be
called with InnerBlock instance as first argument (got ArbitraryBlock
instance instead)
I found a thread that talked about the parent and child being
different types, so I tried setting up the parent class 3 different
ways:
class InnerBlock:
class InnerBlock(obje ct):
class InnerBlock(empt y_class):
where
class empty_class(obj ect):
def __init__(self,_ d={},**kwargs):
kwargs.update(_ d)
self.__dict__=k wargs
I still get the same error. Why doesn't this work?
For some reason you have two InnerBlock classes in your code. A
demonstration:
>>class A(object):
.... def __init__(self): pass
....
>>class B(A):
.... def __init__(self):
.... A.__init__(self )
....
>>B()
<__main__.B object at 0x2b67aae02c90>
>>class A(object):
.... def __init__(self): pass
....
>>B()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in __init__
TypeError: unbound method __init__() must be called with A instance as first
argument (got B instance instead)
Are you perhaps importing your main script into your main script?
Peter This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gonçalo Rodrigues |
last post by:
Hi,
I have a problem with threads and sockets. I'll try to describe the
problem in words with pseudo-code.
I've been working on a few classes to make it easier to work with
threads. This framework, let us call it that, consists in two parts.
The first part is just a basic thread class deriving from
threading.Thread with a few extra functionality that makes it easier
for a thread to spawn a new thread and "father it". Each of its
|
by: Christian Dieterich |
last post by:
Hi,
I need to create many instances of a class D that inherits from a class
B. Since the constructor of B is expensive I'd like to execute it only
if it's really unavoidable. Below is an example and two workarounds,
but I feel they are not really good solutions. Does somebody have any
ideas how to inherit the data attributes and the methods of a class
without calling it's constructor over and over again?
Thank,
|
by: Axel Straschil |
last post by:
Hello!
Im working with new (object) classes and normaly call init of ther
motherclass with callin super(...), workes fine.
No, I've got a case with multiple inherance and want to ask if this is
the right and common case to call init:
class Mother(object):
def __init__(self, param_mother): print 'Mother'
|
by: TPJ |
last post by:
Help me please, because I really don't get it. I think it's some stupid
mistake I make, but I just can't find it. I have been thinking about it
for three days so far and I still haven't found any solution.
My code can be downloaded from here:
http://www.tprimke.net/konto/PyObject-problem.tar.bz2. There are some
scripts for GNU/Linux system (bash to be precise).
All you need to know is that there are four classes. (Of course, you
may...
|
by: .nu |
last post by:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Name: Sleepy Hollow
# Author: .nu
import wx
import os
import sys
| |
by: Tool69 |
last post by:
Hi,
I've got a simple but difficult problem :
Suppose I've got a Paper class, on wich I can draw i.e a rectangle, a
circle or whatever.
class Paper(...):
def __init__(self, paperx, papery):
self.paperx = paperx
self.papery = papery
|
by: Soren |
last post by:
Hi,
I'm trying to create a small GUI program where I can do plots using
Matplotlib. I've been trying to borrow code from the examples at the
matplotlib website, but I can't get it to work.
I want to be able to create a wx.Panel that contains an axis for
plotting. Around it i want other panels containing various settings,
buttons etc. to control the plot. So far I can't even get the program
to actually show a plot in a panel.
|
by: amidzic.branko |
last post by:
I'm trying to solve a problem using inheritance and polymorphism in
python 2.4.2
I think it's easier to explain the problem using simple example:
class shortList:
|
by: Jerry Hill |
last post by:
On Thu, Aug 7, 2008 at 11:11 AM, Ryan Krauss <ryanlists@gmail.comwrote:
This works for me just fine:
class InnerBlock(object):
def __init__(self, codelist, noout=False, **kwargs):
self.codelist = codelist
self.noout = noout
class ArbitraryBlock(InnerBlock):
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |