Got it:
exec('self.' + attr + '=\'' + val + '\'')
That worked. I think it'll do what you want now ;)
Ching-Yun "Xavier" Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http://xavierho.com/
--
http://mail.python.org/mail
>
> val('self.' + attr + '=\'' + val + '\'')
>
Obviously that was eval, not val. Also it doesn't work without the escaped
single quotes, either.
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Jul 22, 2009 at 10:29 PM, Ryniek90 wrote:
> Thanks for hint, but looks like i can't do what i want.
That's because
>
> def _SetVar(self, attr, val):
> self.attr = val
doesn't work as you might think. However, I tried to replace it with:
val('self.' + attr + '=\'' + va
Temat:
Re: Changing the private variables content
Od:
Gary Herron
Data:
Tue, 21 Jul 2009 14:14:44 -0700
Do:
Ryniek90
Do:
Ryniek90
Kopia:
python-list@python.org
Ryniek90 wrote:
Hi.
I'm writing some class, and decided