[Tutor] generating instance names from a list
Karl Fast
karl.fast at pobox.com
Tue Oct 28 18:38:51 EST 2003
> > I've had to resort to this, which seems silly.
> >
> > def somefunc(self):
> > self.alpha = OtherClass()
> > self.beta = OtherClass()
>
> Why is that silly? If you have a fixed set of names this is both
> clear and unambiguous!
AAhh, but you see I don't have a fixed set of names. The program
reads data from a config file and generates objects based on that.
The idea is that I can add a new bit to the config file and viola!,
without editing the code.
Someone else pointed out how to use setattr, which did the trick.
Thanks.
--karl
More information about the Tutor
mailing list