Thanks Bruno, I had to keep coding, so I used the long form
[Object.subobject.property = blah] anyway. It's long-winded, but
unambiguous.
\d
--
http://mail.python.org/mailman/listinfo/python-list
Donn Ingle a écrit :
>>class Key(object):
>>def __init__self):
>>self.__dict__['props'] = KeyProps()
>
> Okay - that's weird.
No, that's coherent. The default behavior (I mean, when there's no
descriptor involved etc) of __setattr__ is to store attributes in
instance.__dict__. So as long a you
> class Key(object):
> def __init__self):
> self.__dict__['props'] = KeyProps()
Okay - that's weird. Is there another way to spin this?
> def __setattr__(self,var,val):
> setattr(self.props,var,val)
Perhaps by changing this one?
\d
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 08 Dec 2007 14:26:00 +0200, Donn Ingle wrote:
>> So you might want to describe your use-case.
> Um.. I wanted an object with Key to hold other data. I wanted a way to
> set that *other* data within Key without having to specify the "object
> in-between" everytime.
That's called "automatic
On Dec 8, 6:06 am, Donn Ingle <[EMAIL PROTECTED]> wrote:
> Hi,
> Here's some code, it's broken:
>
> class Key( object ):
> def __init__(self):
> self.props = KeyProps()
> def __getattr__(self, v):
> return getattr( self.props,v )
> def __setattr__(self,var,val):
>
> So you might want to describe your use-case.
Um.. I wanted an object with Key to hold other data. I wanted a way to set
that *other* data within Key without having to specify the "object
in-between" everytime.
k1.x = "ni!"
should perform:
k1.props.x = "ni!"
and
print k1.x
should perform:
print
Donn Ingle wrote:
> Hi,
> Here's some code, it's broken:
>
>
> class Key( object ):
> def __init__(self):
> self.props = KeyProps()
> def __getattr__(self, v):
> return getattr( self.props,v )
> def __setattr__(self,var,val):
> object.__setattr__(self.props,va
Hi,
Here's some code, it's broken:
class Key( object ):
def __init__(self):
self.props = KeyProps()
def __getattr__(self, v):
return getattr( self.props,v )
def __setattr__(self,var,val):
object.__setattr__(self.props,var,val)
class KeyProps(object):