turning a string into an object name
Marco Herrn
herrn at gmx.net
Thu Apr 4 06:29:03 EST 2002
A. Jones schrieb im Artikel <3cabf705.91920985 at mammoth.usenet-access.com>:
>
> I'll probably get blasted for this by Python gurus... but, I've used
> it with some success. You can do
>
> exec(myObjc + " = " + value)
>
> or, if it's a class instance you want to create
>
> exec(myObjc + " = " + bar + "()").
Thank you. That is possibly the best solution for me. The other answers
I got (thank you all for that) seem to assume that I know possible names
of class instances. But that is not what I want. (Maybe I am just
misunderstanding the code ;-)
Bye
Marco
--
Marco Herrn herrn at gmx.net
(GnuPG/PGP-signed and crypted mail preferred)
Key ID: 0x94620736
More information about the Python-list
mailing list