Re: Private variables

2010-09-01 Thread Rasjid Wilcox
On 2 September 2010 12:22, Ryan Kelly wrote: > On Thu, 2010-09-02 at 12:06 +1000, Ryan Kelly wrote: >> On Thu, 2010-09-02 at 11:10 +1000, Rasjid Wilcox wrote: >> > Hi all, >> > >> > I am aware the private variables are generally done via convention >> &

Re: Private variables

2010-09-01 Thread Ryan Kelly
On Thu, 2010-09-02 at 12:06 +1000, Ryan Kelly wrote: > On Thu, 2010-09-02 at 11:10 +1000, Rasjid Wilcox wrote: > > Hi all, > > > > I am aware the private variables are generally done via convention > > (leading underscore), but I came across a technique in Douglas >

Re: Private variables

2010-09-01 Thread Ryan Kelly
On Thu, 2010-09-02 at 11:10 +1000, Rasjid Wilcox wrote: > Hi all, > > I am aware the private variables are generally done via convention > (leading underscore), but I came across a technique in Douglas > Crockford's book "Javascript: The Good Parts" for creating pri

Private variables

2010-09-01 Thread Rasjid Wilcox
Hi all, I am aware the private variables are generally done via convention (leading underscore), but I came across a technique in Douglas Crockford's book "Javascript: The Good Parts" for creating private variables in Javascript, and I'd thought I'd see how it transla

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
y self._chosen_module gets the value of _chosen_module? Is that you idea of `private variables'? Or do you think that *args does magical things? """Private method which walks through default Python installation directories, and search for prefered module."&qu

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 characteri

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

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 attribute

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: " >>> clas

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(objec

Re: private variables

2007-01-09 Thread Gabriel Genellina
At Tuesday 9/1/2007 04:38, belinda thom wrote: I knew it was a beehive, but I had hoped someone would know which version they were released, so I can put the proper statement into my tutorial (e.g. In version , Python provided some support for private variables...). I've been avoiding ge

Re: private variables

2007-01-09 Thread belinda thom
On Jan 9, 2007, at 12:20 AM, Bruno Desthuilliers wrote: > belinda thom a écrit : >> Hello, >> >> In what version of python were private variables added? > > Which private variables ? Haha. The ones that are provided for convenience (via name mangling) that aren&#

Re: private variables

2007-01-09 Thread Bruno Desthuilliers
belinda thom a écrit : > Hello, > > In what version of python were private variables added? Which private variables ? -- http://mail.python.org/mailman/listinfo/python-list

Re: private variables

2007-01-08 Thread belinda thom
I knew it was a beehive, but I had hoped someone would know which version they were released, so I can put the proper statement into my tutorial (e.g. In version , Python provided some support for private variables...). I've been avoiding getting stung b/c I see both sides and ha

Re: private variables

2007-01-08 Thread Ravi Teja
belinda thom wrote: > Hello, > > In what version of python were private variables added? > > Thanks, > > --b Short answer - 1.5 (or - so long ago that it doesn't matter anymore) Long answer - There are no true private variables in Python. Just private variables names

Re: private variables

2007-01-08 Thread Thomas Ploch
belinda thom schrieb: > Hello, > > In what version of python were private variables added? > > Thanks, > > --b > With this question you stepped into a bee hive. :-) Read the 'Why less emphasis on private data?' thread. But I can't tell you, when this s

private variables

2007-01-08 Thread belinda thom
Hello, In what version of python were private variables added? Thanks, --b -- http://mail.python.org/mailman/listinfo/python-list

Re: "private" variables a.k.a. name mangling (WAS: What is print? A function?)

2005-01-25 Thread Steven Bethard
Toby Dickenson wrote: I have a counterexample. Consider refactoring a class from class B(A): etc into class C(A): etc class B(C): etc Usage of some double-undescore attributes moved from B to the new intermediate base class C. Unit tests on B still passed, so that change is

Re: "private" variables a.k.a. name mangling (WAS: What is print? A function?)

2005-01-25 Thread Richie Hindle
[Toby] > The problem occured because the double-underscore mangling uses the class > name, but ignores module names. A related project already had a class named C > derived from B (same name - different module). Yikes! A pretty bizarre case, but nasty when it hits. I guess the double-undersc

Re: "private" variables a.k.a. name mangling (WAS: What is print? A function?)

2005-01-25 Thread Philippe C. Martin
Well I _was_ a bit slow on that one ! So I will happily stick to the double underscore. Regards, Philippe Le mardi 25 janvier 2005 Ã 10:28 +, Simon Brunning a Ãcrit : > On Mon, 24 Jan 2005 12:17:13 -0600, Philippe C. Martin > <[EMAIL PROTECTED]> wrote: > > > &g

Re: RE:"private" variables a.k.a. name mangling (WAS: What is print? A function?)

2005-01-25 Thread Sion Arrowsmith
Jeremy Bowers <[EMAIL PROTECTED]> wrote: > [ ... ] the Python community, and in general the dynamic language >community, has become increasingly confident that private variables don't >solve *real* problems. Years of writing and maintaining others' C++ and Java code (plu

Re: "private" variables a.k.a. name mangling (WAS: What is print? A function?)

2005-01-25 Thread Toby Dickenson
On Tuesday 25 January 2005 12:40, Richie Hindle wrote: > > [Steven] > > Can someone give me an example of where __-mangling really solved a problem > > for them, where a simple leading underscore wouldn't have solved the > > same problem? > > http://cvs.sourceforge.net/viewcvs.py/spambayes/sp

Re: "private" variables a.k.a. name mangling (WAS: What is print? A function?)

2005-01-25 Thread Richie Hindle
[Steven] > Can someone give me an example of where __-mangling really solved a problem > for them, where a simple leading underscore wouldn't have solved the > same problem? http://cvs.sourceforge.net/viewcvs.py/spambayes/spambayes/spambayes/Dibbler.py?r1=1.13&r2=1.13.4.1 That's a bugfix to Sp

Re: "private" variables a.k.a. name mangling (WAS: What is print? A function?)

2005-01-25 Thread michele . simionato
>Name mangling is there to keep you from accidentally hiding such an >attribute in a subclass, but how often is this really a danger? Can >someone give me an example of where __-mangling really solved a problem >for them, where a simple leading underscore wouldn't have solved the >same problem? Lo

Re: "private" variables a.k.a. name mangling (WAS: What is print? A function?)

2005-01-25 Thread Simon Brunning
On Mon, 24 Jan 2005 12:17:13 -0600, Philippe C. Martin <[EMAIL PROTECTED]> wrote: > > I use "__"for private variables because I must have read on net it was > the way to do so - yet this seems to have changed - thanks: > > http://www.network-theory.co.uk/docs/

Re: Why I use private variables (WAS: RE:"private" variables a.k.a. name mangling?)

2005-01-24 Thread Steven Bethard
Philippe C. Martin wrote: I used double underscore because I thought it was the correct way to name private variables/methods - I will have to change those to single underscore since that it the current methodology. A private variable to me: 1) is internal to the processing of a class and needs

RE: Why I use private variables (WAS: RE:"private" variables a.k.a. name mangling?)

2005-01-24 Thread Philippe C. Martin
I used double underscore because I thought it was the correct way to name private variables/methods - I will have to change those to single underscore since that it the current methodology. A private variable to me: 1) is internal to the processing of a class and needs not be accessed by external

RE: Why I use private variables (WAS: RE:"private" variables a.k.a. name mangling?)

2005-01-24 Thread Jeremy Bowers
On Mon, 24 Jan 2005 15:35:11 -0600, Philippe C. Martin wrote: > The real reason behind my using private variables is so they do not appear > in the epydoc generated documentation and confuse my users. You mean single or double underscores? I just checked and at least epydoc 2.1 doesn

RE: Why I use private variables (WAS: RE:"private" variables a.k.a. name mangling?)

2005-01-24 Thread Philippe C. Martin
The real reason behind my using private variables is so they do not appear in the epydoc generated documentation and confuse my users. Regards, Philippe -- *** Philippe C. Martin SnakeCard LLC www.snakecard.com *** -- http://mail.python.org

Re: RE:"private" variables a.k.a. name mangling (WAS: What is print? A function?)

2005-01-24 Thread Jeremy Bowers
On Mon, 24 Jan 2005 12:17:13 -0600, Philippe C. Martin wrote: > I use "__"for private variables because I must have read on net it was the > way to do so - yet this seems to have changed - It's still as true as ever, at least in terms of language support, it's just that

RE:"private" variables a.k.a. name mangling (WAS: What is print? A function?)

2005-01-24 Thread Philippe C. Martin
I use "__"for private variables because I must have read on net it was the way to do so - yet this seems to have changed - thanks: http://www.network-theory.co.uk/docs/pytut/tut_77.html As far as the specific stderr reroute example - I just grabbed some of my code and forgot to get r

"private" variables a.k.a. name mangling (WAS: What is print? A function?)

2005-01-24 Thread Steven Bethard
Philippe C. Martin wrote: > class Debug_Stderr: > __m_text = '' > __m_log_text = None > __m_dbg = None > __m_refresh_count = 0 I don't see the benefit in 99.9% of cases for making class variables like this "private". If you don't want people to use them, simply use the standard conventi