extended setattr()

Rotlaus rotlaus at gmail.com
Mon Jul 7 02:01:45 EDT 2008


2 weeks ago i asked for a etended getattr() which worked really fine,
but now i would love to have a extended setattr() as well.

Lets assume i have some classes:

class A(object):
    def __init__(self):
        self.B = B()

class B(object):
    def __init__(self):
        self.C = C()

class C(object):
    def __init__(self, foo='', bar=''):
        self.foo = foo
        self.bar = bar

and now i wanna do something like this:

a=A()
ext_setattr(a, 'B.C', ('a', 'b'))

Is this possible? It would also be nice if the attributes would be
created if they not exist, always implying that
objectname==objecttype.

Kind regards,

Andre



More information about the Python-list mailing list