I tried that and super(B,self), but neither works.
Using super(A,self) in the _getv(self) method doesn't work, since the
super() of A is "object" and that doesn't have the v property at all.
Not sure why you say that using self.__class__ is wrong as the first
argument to super(), it should be th
David Hirschfield <[EMAIL PROTECTED]> writes:
> 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 trouble, I know it won't work, but
> it illustrate
David Hirschfield wrote:
> So, the larger question is how to do anything that resembles what I
> want, which is to have a chain of subclasses with a single attribute
> that each subclass can define as it wishes to, but with the ability to
> get the combined value from all the ancestors down to t
Yes, indeed that does work.
I tried using __mro__ based on some code that showed how super() works
in pure-python, but I got lost.
I think this makes that clear...tho' I hate squishing around in instance
innards like this...
Thanks a bunch, I'm sure I'll have more questions,
-Dave
Paul McNett w
David Hirschfield wrote:
> Here's an example that's giving me trouble, I know it won't work, but it
> illustrates what I want to do:
>
> class A(object):
>_v = [1,2,3]
> def _getv(self):
>if self.__class__ == A:
>return self._v
>return super(self.__class__,sel
David Hirschfield wrote:
> I tried that and super(B,self), but neither works.
>
> Using super(A,self) in the _getv(self) method doesn't work, since the
> super() of A is "object" and that doesn't have the v property at all.
> Not sure why you say that using self.__class__ is wrong as the first
>
David Hirschfield wrote:
> Is there a way to get what I'm after using super()?
Probably.
> The idea is that I could have a chain of subclasses which only need to
> redefine _v, and getting the value of v as a property would give me back
> the full chain of _v values for that class and all its
Good point, I did notice that.
My example is total junk, actually. Now that I look at it, it isn't at
all possible to do what I'm after this way, since _getv() is never going
to be looking at class A's _v value.
So, the larger question is how to do anything that resembles what I
want, which is
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 trouble, I know it won't work, but it
illustrates what I want to do:
class A(object):
_v = [1,2,3
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 co
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, s
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__
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
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 __
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)
Typ
15 matches
Mail list logo