On Thu, Oct 18, 2012 at 10:51 AM, Dave Angel wrote:
> On 10/18/2012 10:10 AM, Jeff Jeffries wrote:
> > Hello everybody
> >
> > When I set "AttributeChanges" in my example, it sets the same value for
> all
> > other subclasses. Can someone help me with what the name of this behavior
> > is (mutabl
On 10/18/2012 10:10 AM, Jeff Jeffries wrote:
> Hello everybody
>
> When I set "AttributeChanges" in my example, it sets the same value for all
> other subclasses. Can someone help me with what the name of this behavior
> is (mutable class global?) ? I don't know any keywords... having
> troubl
On 18 October 2012 15:10, Jeff Jeffries wrote:
> Hello everybody
>
> When I set "AttributeChanges" in my example, it sets the same value for all
> other subclasses. Can someone help me with what the name of this behavior is
> (mutable class global?) ? I don't know any keywords... having troub
Preamble: when posting a brand new question, you'd better not replying to
an existing completely unrelated message. In most viewers, this will cause
your message to appear in the thread for the original question and far
less people will see it. So better create a brand new thread.
On Fri, 2
On Fri, Jun 20, 2008 at 6:19 PM, Hamish McKenzie
<[EMAIL PROTECTED]> wrote:
>
> I have this class:
>
> class Vector(object):
> TOL = 1e-5
> def __eq__( self, other, tolerance=TOL ):
> print tolerance
>
>
> shortened for clarity obviously. so I want to subclass this class like
> s
Hi all,
I would like to thank you all for all the suggestions.
what I did was simply extending the super class data with data from
its child
using the id example, Foo.id = 1 is now = [1] and the FooSon does
self.id.append(2)
the system designer wanted inheritance+java and I wanted Python
+Functi
On Mar 25, 12:01 pm, Robert Bossy <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm not sure what you're trying to actually achieve, but it seems that
> you want an identificator for classes, not for instances. In this case,
> setting the id should be kept out of __init__ since it is an instance
> initializ
Hi,
I'm not sure what you're trying to actually achieve, but it seems that
you want an identificator for classes, not for instances. In this case,
setting the id should be kept out of __init__ since it is an instance
initializer: make id static and thus getid() a classmethod.
Furthermore, if yo
On Mar 25, 4:37 pm, Brian Lane <[EMAIL PROTECTED]> wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
>
>
> Gerard Flanagan wrote:
> > Use the child class when calling super:
>
> > --
> > class Foo(object):
> > def __init__(self):
> > self.id
On Tue, 25 Mar 2008 16:37:00 +0100, Brian Lane <[EMAIL PROTECTED]> wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Gerard Flanagan wrote:
>
>> Use the child class when calling super:
>>
>> --
>> class Foo(object):
>> def __init__(self):
>>
Anthony wrote:
> On Mar 25, 2:31 pm, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote:
>> I wish it was that simple but 'a = Foo().getid()' is actually creating
>> a new instance of Foo whereas I want the data of the Foo instanced by
>> __init__ of FooSon().
>
> I don't think Foo.__init__(self) creates
Brian Lane <[EMAIL PROTECTED]> writes:
> Basically, you can't do what you are trying to do without using a
> different variable,
...or abusing the __foo private identifier trick.
--
http://mail.python.org/mailman/listinfo/python-list
Tzury Bar Yochay <[EMAIL PROTECTED]> writes:
> given two classes:
>
> class Foo(object):
> def __init__(self):
> self.id = 1
>
> def getid(self):
> return self.id
>
> class FooSon(Foo):
> def __init__(self):
> Foo.__init__(self)
> self.id = 2
>
> def
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Gerard Flanagan wrote:
> Use the child class when calling super:
>
> --
> class Foo(object):
> def __init__(self):
> self.id = 1
>
> def getid(self):
> return self.id
>
> class FooSon(Foo)
On Mar 25, 2:31 pm, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote:
> I wish it was that simple but 'a = Foo().getid()' is actually creating
> a new instance of Foo whereas I want the data of the Foo instanced by
> __init__ of FooSon().
I don't think Foo.__init__(self) creates an instance of the Foo
c
On Mar 25, 1:34 pm, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote:
> > Rather than use Foo.bar(), use this syntax to call methods of the
> > super class:
>
> > super(ParentClass, self).method()
>
> Hi Jeff,
> here is the nw version which cause an error
>
> class Foo(object):
> def __init__(self):
On Mar 25, 4:03 pm, Anthony <[EMAIL PROTECTED]> wrote:
> On Mar 25, 11:44 am, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote:
>
> > While my intention is to get 1.2 I get 2.2
> > I would like to know what would be the right way to yield the expected
> > results
>
> Is this what you want?
>
> class Foo(
On Mar 25, 11:44 am, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote:
> While my intention is to get 1.2 I get 2.2
> I would like to know what would be the right way to yield the expected
> results
Is this what you want?
class Foo(object):
def __init__(self):
self.id = 1
def getid(sel
In the derived class init you set self.id to 2 so
when you call getid method it just returns self.id which is now 2.
you can use another variable name.
On Tue, Mar 25, 2008 at 1:44 PM, Tzury Bar Yochay <[EMAIL PROTECTED]>
wrote:
> given two classes:
>
> class Foo(object):
>def __init__(self):
a = super(Foo, self).getid()
should be
a = super(FooSon, self).getid()
On Tue, Mar 25, 2008 at 2:34 PM, Tzury Bar Yochay <[EMAIL PROTECTED]>
wrote:
> > Rather than use Foo.bar(), use this syntax to call methods of the
> > super class:
> >
> > super(ParentClass, self).method()
>
> Hi Jeff,
> here
> Rather than use Foo.bar(), use this syntax to call methods of the
> super class:
>
> super(ParentClass, self).method()
Hi Jeff,
here is the nw version which cause an error
class Foo(object):
def __init__(self):
self.id = 1
def getid(self):
return self.id
class FooSon(F
On Mar 25, 2:00 pm, John Machin <[EMAIL PROTECTED]> wrote:
> On Mar 25, 10:44 pm, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote:
>
>
>
> > given two classes:
>
> > class Foo(object):
> > def __init__(self):
> > self.id = 1
>
> > def getid(self):
> > return self.id
>
> > class F
On Mar 25, 10:44 pm, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote:
> given two classes:
>
> class Foo(object):
> def __init__(self):
> self.id = 1
>
> def getid(self):
> return self.id
>
> class FooSon(Foo):
> def __init__(self):
> Foo.__init__(self)
> self
Rather than use Foo.bar(), use this syntax to call methods of the
super class:
super(ParentClass, self).method()
--
http://mail.python.org/mailman/listinfo/python-list
Jackson wrote:
> For a more "concrete" example:
>
> Suppose all the animals in the world have only 1 or 2 legs.
>
> class Legs(object)
> def run(): pass
> def walk(number_of_legs):
> # lots of commands
> # that do not depend on the
> # number of legs but definitely
> # have to d
Gabriel Genellina wrote:
> At Saturday 11/11/2006 03:31, Frank Millman wrote:
>
> >Continuing your analogy of animals, assume a class A with a 'walk'
> >method and an 'eat' method.
> >
> >Most animals walk the same way, but a few don't, so I create a subclass
> >AW and override the walk method.
>
At Saturday 11/11/2006 03:31, Frank Millman wrote:
Continuing your analogy of animals, assume a class A with a 'walk'
method and an 'eat' method.
Most animals walk the same way, but a few don't, so I create a subclass
AW and override the walk method.
Most animals eat the same way, but a few do
Jackson wrote:
> I've got an inheritance question and was hoping brighter minds could
> guide me. I am in the strange situation where some of the methods in a
> subclass are actually more general than methods in a superclass. What
> is the preferred way to handle such situations. My original th
Gabriel Genellina wrote:
> If walking in general, have some common structure, you can put the
> "sketch" on Legs and let the derived classes "fill the gaps". This is
> known as "Template Method Pattern" - look for it.
Or if you'd rather see a concrete example, here's how your toy example
would lo
At Friday 10/11/2006 21:13, Jackson wrote:
I've got an inheritance question and was hoping brighter minds could
guide me. I am in the strange situation where some of the methods in a
subclass are actually more general than methods in a superclass. What
is the preferred way to handle such situa
30 matches
Mail list logo