Bug or wart? You make the call.

Alex A. Naanou alex_nanou at pochtamt.ru
Sat Mar 8 18:20:32 EST 2003


I stand corrected (that was a bit hasty of me :) )
Thanks Terry.

here is the *error free* version of the code from my last post:
---cut---
class X(object):
    def meth(self):pass

x = X()

# the ways to go in the current state:
# proposed above:
X.__dict__['meth'].attr1 = 1

# another way that works:
x.meth.__setattr__('attr2', 2)
X.meth.__setattr__('attr3', 3)

print x.meth.attr0, x.meth.attr1, x.meth.attr2, x.meth.attr3
# will print "0 1 2 3"

# so why not make this work as well:
## x.meth.attr4 = 4

---uncut---

                                             Best Regards...
                                                       Alex.




More information about the Python-list mailing list