Using eval, or something like it...
James Mills
prologic at shortcircuit.net.au
Wed Nov 19 20:12:56 EST 2008
DON'T USE eval!
On Thu, Nov 20, 2008 at 10:44 AM, r0g <aioe.org at technicalbloke.com> wrote:
> Hi There,
>
> I know you can use eval to dynamically generate the name of a function
> you may want to call. Can it (or some equivalent method) also be used to
> do the same thing for the variables of a class e.g.
>
> class Foo():
> bar = 1
> gum = 2
>
> mylist = ['bar','gum']
>
> a = Foo()
> for each in mylist:
> a.eval(each) = 999
>
>
> If so, what is the proper syntax/method for this.
>
> Regards,
>
> Roger.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
--
-- "Problems are solved by method"
More information about the Python-list
mailing list