Variable names on the fly?

Alex Martelli aleax at aleax.it
Thu Nov 14 15:15:46 EST 2002


Gerhard Häring wrote:
   ...
> OTOH being able to dynamically create class attributes by writing in
> the class object's __dict__ or by overriding __getattr__ sometimes
> really helps.

Another often-helpful way to create attributes with runtime-computed
names for any object that support general arbitrary attributes (classes,
instances, functions, modules, ...) is built-in function setattr.


Alex




More information about the Python-list mailing list