To make a method or attribute private

2013-01-20 Thread iMath
To make a method or attribute private (inaccessible from the outside), simply start its name with two underscores 《Beginning Python From Novice to Professional》 but there is another saying goes: Beginning a variable name with a single underscore indicates that the variable should

Re: To make a method or attribute private

2013-01-20 Thread Chris Angelico
On Sun, Jan 20, 2013 at 8:17 PM, iMath redstone-c...@163.com wrote: so what is your opinion about single leading underscore and private methods or attributes? Didn't this get discussed recently? http://mail.python.org/pipermail/python-list/2013-January/638687.html ChrisA --

Re: To make a method or attribute private

2013-01-20 Thread iMath
在 2013年1月17日星期四UTC+8上午9时04分00秒,alex23写道: On Jan 17, 10:34 am, iMath 2281570...@qq.com wrote: To make a method or attribute private (inaccessible from the outside), simply start its name with two underscores but there is another saying goes: Beginning a variable name

Re: To make a method or attribute private

2013-01-20 Thread Steven D'Aprano
On Sun, 20 Jan 2013 06:52:32 -0800, iMath wrote: [snip many dozens of lines of irrelevant text] what's the meaning of 'object' in class A(object) and class B(object) ? Please trim your replies. We don't need to scroll past page after page of irrelevant text which we have already read.

Re: To make a method or attribute private

2013-01-20 Thread alex23
On Jan 20, 7:23 pm, Chris Angelico ros...@gmail.com wrote: On Sun, Jan 20, 2013 at 8:17 PM, iMath redstone-c...@163.com wrote: so what is your opinion about single leading underscore and private methods or attributes? Didn't this get discussed recently?

Re: To make a method or attribute private

2013-01-20 Thread Dave Angel
On 01/20/2013 06:14 PM, alex23 wrote: On Jan 20, 7:23 pm, Chris Angelico ros...@gmail.com wrote: On Sun, Jan 20, 2013 at 8:17 PM, iMath redstone-c...@163.com wrote: so what is your opinion about single leading underscore and private methods or attributes? Didn't this get discussed recently?

Re: To make a method or attribute private

2013-01-20 Thread iMath
在 2013年1月17日星期四UTC+8上午8时34分22秒,iMath写道: To make a method or attribute private (inaccessible from the outside), simply start its  name with two underscores 《Beginning Python From Novice to Professional》 but there is another saying goes: Beginning a variable name with a single

Re: To make a method or attribute private

2013-01-20 Thread Chris Angelico
On Mon, Jan 21, 2013 at 12:14 PM, iMath redstone-c...@163.com wrote: so there is no REAL private variable in Python but conversion exists in it that python programmer should follow and recognize .right ? That's about it. If you think about C++ public members as the interface and

Re: To make a method or attribute private

2013-01-20 Thread alex23
On Jan 21, 9:32 am, Dave Angel d...@davea.name wrote: On 01/20/2013 06:14 PM, alex23 wrote: On Jan 20, 7:23 pm, Chris Angelico ros...@gmail.com wrote: On Sun, Jan 20, 2013 at 8:17 PM, iMath redstone-c...@163.com wrote: so what is your opinion about single leading underscore and private

Re: To make a method or attribute private

2013-01-20 Thread Mitya Sirenef
On 01/20/2013 09:24 PM, alex23 wrote: On Jan 21, 9:32 am, Dave Angel d...@davea.name wrote: On 01/20/2013 06:14 PM, alex23 wrote: On Jan 20, 7:23 pm, Chris Angelico ros...@gmail.com wrote: On Sun, Jan 20, 2013 at 8:17 PM, iMath redstone-c...@163.com wrote: so what is your opinion about

Re: To make a method or attribute private

2013-01-20 Thread Steven D'Aprano
On Sun, 20 Jan 2013 17:14:36 -0800, iMath wrote: [...] so there is no REAL private variable in Python but conversion exists in it that python programmer should follow and recognize .right ? There are no REAL private variables in most languages. Consider the C++ trick #define private public.

Re: To make a method or attribute private

2013-01-20 Thread Chris Angelico
On Mon, Jan 21, 2013 at 2:27 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sun, 20 Jan 2013 17:14:36 -0800, iMath wrote: [...] so there is no REAL private variable in Python but conversion exists in it that python programmer should follow and recognize .right ? There

Re: To make a method or attribute private

2013-01-20 Thread alex23
On Jan 21, 2:46 pm, Chris Angelico ros...@gmail.com wrote: These aren't proofs that something doesn't exist, they're proofs that trying to enforce privacy is bound to fail But if you can't enforce it, can you really say it exists? Semantics, they are fun! I feel another PyWart post coming

Re: To make a method or attribute private

2013-01-17 Thread Lie Ryan
On 17/01/13 11:34, iMath wrote: To make a method or attribute private (inaccessible from the outside), simply start its name with two underscores 《Beginning Python From Novice to Professional》 but there is another saying goes: Beginning a variable name with a single underscore indicates

Re: To make a method or attribute private

2013-01-16 Thread alex23
On Jan 17, 10:34 am, iMath 2281570...@qq.com wrote: To make a method or attribute private (inaccessible from the outside), simply start its name with two underscores but there is another saying goes: Beginning a variable name with a single underscore indicates that the variable should

Re: To make a method or attribute private

2013-01-16 Thread Steven D'Aprano
On Thu, 17 Jan 2013 08:34:22 +0800, iMath wrote: divdivTo make a method or attribute private (inaccessible from the outside), simply start itsnbsp;/divdivname with two underscores/divdivbr/divdiv《Beginning Python From Novice to Professional》/divdivbr/divdivbut there is another saying