Hi,
I'm writing a bunch of abstract classes and I'd like to delegate the
arguments of the concrete class the to abstract one. I was surprised
to see that the print statement in the abstract class isn't executed.
But moreover, I'd like to find out an idiom that allows one to
delegate arguments in the inherited class. Any ideas?
Thanks,
-jelle
class Abstract(object):
def __init__(self, a='a', b='b'):
self.a, self.b = a, b
print a, b
class Concrete(Abstract):
def __init__(self, a='AAA', b='BBB'):
super(Abstract, self).__init__( a=a, b=b )
print a, b
c = Concrete(a=1)
>>c = Concrete(a=1)
1 BBB 4 932
On Thu, 06 Sep 2007 16:12:11 +0000, jelle wrote:
Hi,
I'm writing a bunch of abstract classes and I'd like to delegate the
arguments of the concrete class the to abstract one. I was surprised to
see that the print statement in the abstract class isn't executed. But
moreover, I'd like to find out an idiom that allows one to delegate
arguments in the inherited class. Any ideas?
Change the call to super() in Concrete from:
super(Abstract, self).__init__(a, b)
to
super(Concrete, self).__init__(a, b)
--
Steven.
Ai, calling super(Abstract) is just getting object, sure...
However, I'm still curious to know if there's a good idiom for
repeating the argument in __init__ for the super(Concrete,
self).__init__ ?
Thanks,
-jelle
Ai, calling super(Abstract) is just getting object, sure...
However, I'm still curious to know if there's a good idiom for
repeating the argument in __init__ for the super(Concrete,
self).__init__ ?
Thanks,
-jelle
On Sep 6, 11:18 am, jelle <jelleferi...@gmail.comwrote:
Ai, calling super(Abstract) is just getting object, sure...
However, I'm still curious to know if there's a good idiom for
repeating the argument in __init__ for the super(Concrete,
self).__init__ ?
If you don't know what the arguments are, you can use *args and
**kwargs.
class Concrete(Abstract):
def __init__(self, *args, **kwargs):
super(Concrete, self).__init__(*args, **kwargs) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dan Perl |
last post by:
There is something with initializing mutable class attributes that I am
struggling with. I'll use an example to explain:
class Father:
attr1=None # this is OK
attr2= # this is wrong...
|
by: Dan Perl |
last post by:
Here is a problem I am having trouble with and I hope someone in this group
will suggest a solution. First, some code that works. 3 classes that are
derived from each other (A->B->C), each one...
|
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...
|
by: Dave |
last post by:
Hello all,
I have a class that contains a large number of discrete pieces of state
information. Any combination of these member variables might be valid for a
given object. Any given member...
|
by: Aengys |
last post by:
Hi all,
Being struck by article 7421 of the linux journal
(http://www.linuxjournal.com/article/7421), I'll tried to give it a go.
Mainly because I have done some experiments with Glade and found...
|
by: Calle Pettersson |
last post by:
Coming from writing mostly in Java, I have trouble understanding how to
declare a member without initializing it, and do that later... In Java,
I would write something like
public static void...
|
by: John |
last post by:
Hello,
is there any compiler option for g++ for initializing static members of the
class.
Due to some unknown reason, static member in one of our c++ application is
not getting initialized...
|
by: Akihiro KAYAMA |
last post by:
Hi all.
I found cooperative multi-threading(only one thread runs at once,
explicit thread switching) is useful for writing some simulators.
With it, I'm able to be free from annoying mutual...
|
by: Reckoner |
last post by:
would it be possible to use one of an object's methods without
initializing the object?
In other words, if I have:
class Test:
def __init__(self):
print 'init'
def foo(self):
print 'foo'
|
by: WaterWalk |
last post by:
Hello. When I consult the ISO C++ standard, I notice that in
paragraph 3.6.2.1, the standard states:
"Objects with static storage duration shall be zero-initialized before
any other...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| |