Class initialization from a dictionary, how best?

brianobush at gmail.com brianobush at gmail.com
Fri Jan 14 10:32:06 EST 2005


Yes, my examle here is a tiny part of a larger more complex issue. My
application is an DOM XML parser that is reading attributes one at a
time. My class that I am creating is used elsewhere and must have
certain arguments for those uses to continue working. So, I seem to be
left with creating an intermediate object. Before, I was simply
creating an object:

t = Test()
for attr_name in mapping.keys():
setattr(t, attr_name, value_from_source)

This I feel was ellegant, efficient and clear. However, what I have now
works but is not clear.
BTW, t1 is just for example and was just being printed
Thanks, Brian




More information about the Python-list mailing list