Suppose I have a python object x and a string s, how do I set the attribute s on x? So:

>>> x = SomeObject()
>>> attr="myAttr"
>>> # magic goes here
>>> x.myAttr
'magic'

What’s the magic? The goal of this, incidentally, is to cache calls to x.__getattr__().

4 Answers
4

Leave a Reply

Your email address will not be published. Required fields are marked *