Thanks to Andreas Waldenburger, THC4k (http://stackoverflow.com/
questions/4247036/python-recursively-getattribute) and others for
their tips. I was able to find solution:
class Null(object):
def __repr__(self):
return ""
def __str__(self):
return ''
def __nonzero__(s
On 22 nov, 21:44, Roman Dolgiy wrote:
>> http://stackoverflow.com/questions/4247036/python-recursively-getattr...
>
> I need to support a lot of legacy code, with THC4k's approach I'll
> have to modify project's existing code to use obj.attr1.val instead of
> obj.attr1 but this is not suitable.
Y
On Nov 22, 7:57 pm, Terry Reedy wrote:
> On 11/22/2010 10:46 AM, Roman Dolgiy wrote:
>
> > Hello,
>
> > I need to implement such behavior:
>
> > obj.attr1.attr2.attr3 --> obj.attr1__attr2__attr3
>
> obj.attr1.attr2.attr3 is parsed as ((obj.attr1).attr2).attr3,
> so this cannot work in general but
On 11/22/2010 10:46 AM, Roman Dolgiy wrote:
Hello,
I need to implement such behavior:
obj.attr1.attr2.attr3 --> obj.attr1__attr2__attr3
obj.attr1.attr2.attr3 is parsed as ((obj.attr1).attr2).attr3,
so this cannot work in general but only if attr1 and attr2 are known to
not be 'final' names.
On Mon, 22 Nov 2010 08:41:49 -0800 (PST) Roman Dolgiy wrote:
> On Nov 22, 6:04 pm, Andreas Waldenburger
> wrote:
> > On Mon, 22 Nov 2010 07:46:47 -0800 (PST) Roman Dolgiy
> > wrote:
> >
> > > Hello,
> >
> > > I need to implement such behavior:
> >
> > > obj.attr1.attr2.attr3 --> obj.attr1__attr
On Nov 22, 6:04 pm, Andreas Waldenburger
wrote:
> On Mon, 22 Nov 2010 07:46:47 -0800 (PST) Roman Dolgiy
> wrote:
>
> > Hello,
>
> > I need to implement such behavior:
>
> > obj.attr1.attr2.attr3 --> obj.attr1__attr2__attr3
> > It looks like I have to override obj's class __getattribute__ and als
On Mon, 22 Nov 2010 07:46:47 -0800 (PST) Roman Dolgiy wrote:
> Hello,
>
> I need to implement such behavior:
>
> obj.attr1.attr2.attr3 --> obj.attr1__attr2__attr3
> It looks like I have to override obj's class __getattribute__ and also
> use python descriptors somehow.
>
> Any help will be muc
Hello,
I need to implement such behavior:
obj.attr1.attr2.attr3 --> obj.attr1__attr2__attr3
It looks like I have to override obj's class __getattribute__ and also
use python descriptors somehow.
Any help will be much appreciated.
http://stackoverflow.com/questions/4247036/python-recursively-geta