In <639908184290880449.447600deets-nospam.web...@news.hansenet.de> Diez B. Roggisch <de...@nospam.web.de> writes:
>You don't. Python is not Java. So just use instance attributes, and if >you need bhavior when accessing an attribute, introduce a property. Just accessing attributes looks a bit dangerous to me, due to bugs like typing i.typo = 'foo' when what you meant is i.type = 'foo' I tried fixing this by mucking with __setattr__, but I didn't hit on a satisfactory solution (basically, I couldn't find a good, self-maintaining, way to specify the attributes that were OK to set from those that weren't). Is there anything built-in? Regarding properties, is there a built-in way to memoize them? For example, suppose that the value of a property is obtained by parsing the contents of a file (specified in another instance attribute). It would make no sense to do this parsing more than once. Is there a standard idiom for memoizing the value once it is determined for the first time? Thanks! ~K -- http://mail.python.org/mailman/listinfo/python-list