Re: Help with super()

2006-01-13 Thread David Hirschfield
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

Re: Help with super()

2006-01-13 Thread Mike Meyer
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

Re: Help with super()

2006-01-13 Thread Paul McNett
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

Re: Help with super()

2006-01-13 Thread David Hirschfield
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

Re: Help with super()

2006-01-13 Thread Steven Bethard
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

Re: Help with super()

2006-01-12 Thread Paul McNett
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 >

Re: Help with super()

2006-01-12 Thread Paul McNett
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

Re: Help with super()

2006-01-12 Thread David Hirschfield
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

Help with super()

2006-01-12 Thread David Hirschfield
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

Re: Help with super()

2004-12-07 Thread Christopher J. Bottaro
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

Re: Help with super()

2004-12-07 Thread Andy Gross
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

Re: Help with super()

2004-12-07 Thread Florian Lindner
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__

Re: Help with super()

2004-12-06 Thread Steven Bethard
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

Re: Help with super()

2004-12-06 Thread Peter Otten
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 __

Help with super()

2004-12-06 Thread Christopher J. Bottaro
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