Re: Changing the private variables content

2009-07-23 Thread Ethan Furman
Or, in other words, what Steven D'Aprano had already said. Guess I should read the whole thread before madly posting! :) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Changing the private variables content

2009-07-23 Thread Ethan Furman
Ryniek90 wrote: 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: htt

Re: Changing the private variables content

2009-07-22 Thread Piet van Oostrum
> Ryniek90 (R) wrote: >R> It looks like private variable have specific naure, that prevent from >R> traditional editing them. >R> Still searching for some tuts about private methods and variables. Why do you stubbornly keep saying that, while you have been told that it is not the case. Inste

Re: Changing the private variables content

2009-07-22 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Wed, 22 Jul 2009 14:29:20 +0200, Ryniek90 wrote: When i use this class in Python IDLE, i've got this error: " ... Traceback (most recent call last): File "", line 1, in mod.print_module('socket') File "", line 48, in print_module module_open =

Re: Changing the private variables content

2009-07-22 Thread Dave Angel
Ryniek90 wrote: It looks like private variable have specific naure, that prevent from traditional editing them. Still searching for some tuts about private methods and variables. There's no tutorial on private variables for good reason: Private variables have no special characteristics.

Re: Changing the private variables content

2009-07-22 Thread Ryniek90
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/

Re: Changing the private variables content

2009-07-22 Thread Steven D'Aprano
On Wed, 22 Jul 2009 14:29:20 +0200, Ryniek90 wrote: > When i use this class in Python IDLE, i've got this error: " ... > Traceback (most recent call last): > File "", line 1, in > mod.print_module('socket') > File "", line 48, in print_module > module_open = open(self._this_module, 'r

Re: Changing the private variables content

2009-07-22 Thread Xavier Ho
> What is the point of the _SetVar method? > > So you can set any variable in that class, I guess? -- http://mail.python.org/mailman/listinfo/python-list

Re: Changing the private variables content

2009-07-22 Thread MRAB
Ryniek90 wrote: 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

Re: Re: Changing the private variables content

2009-07-22 Thread Xavier Ho
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

Re: Re: Changing the private variables content

2009-07-22 Thread Xavier Ho
> > 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

Re: Re: Changing the private variables content

2009-07-22 Thread Xavier Ho
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

Re: Re: Changing the private variables content

2009-07-22 Thread Ryniek90
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 de

Re: Changing the private variables content

2009-07-21 Thread David Stanek
On Tue, Jul 21, 2009 at 6:00 PM, Rhodri James wrote: > On Tue, 21 Jul 2009 21:55:18 +0100, Ryniek90 wrote: > >> Hi. >> I'm writing some class, and decided to use inside private method and some >> private variables. While with method i haven't got any problem's with >> variables i have. > > There i

Re: Changing the private variables content

2009-07-21 Thread Rhodri James
On Tue, 21 Jul 2009 21:55:18 +0100, Ryniek90 wrote: Hi. I'm writing some class, and decided to use inside private method and some private variables. While with method i haven't got any problem's with variables i have. There is no mechanism in Python that makes attributes truly private. se

Re: Changing the private variables content

2009-07-21 Thread Gary Herron
Ryniek90 wrote: Hi. I'm writing some class, and decided to use inside private method and some private variables. While with method i haven't got any problem's with variables i have. Maybe some example. A class with private method and private variable: " >>> class Secret(object): # def _

Changing the private variables content

2009-07-21 Thread Ryniek90
Hi. I'm writing some class, and decided to use inside private method and some private variables. While with method i haven't got any problem's with variables i have. Maybe some example. A class with private method and private variable: " >>> class Secret(object): # def __init__(self):