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 FooSon(Foo):
> > def __init__(self):
> > Foo.__init__(self)
> > self.id = 2
>
> > def getid(self):
> > a = Foo.getid()
> > b = self.id
> > return '%d.%d' % (a,b)
>
> > 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
>
> Post the code that you actually executed. What you have shown lacks
> the code to execute it ... but the execution will fail anyway:
>
> a = Foo.getid()
> TypeError: unbound method getid() must be called with Foo instance as
> first argument (got nothing instead)
sorry, it should have been:
a = Foo.getid(self)
instead of
a = Foo.getid()
--
http://mail.python.org/mailman/listinfo/python-list