[IronPython] Codeplex Issue:

Michael Foord fuzzyman at voidspace.org.uk
Wed Nov 12 08:24:10 CET 2008


Hello guys,

Sorry to do this by email, but I'm travelling (anyone on list going to 
be at PyWorks?)  and the internet connection is too ropey for me to 
comment directly on Codeplex.

I wanted to make a (minor!) comment regarding Codeplex issue 19488.

http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=19488

In general it is great - IronPython samples *should* follow PEP 8 as 
much as possible (how come Ruby guys got nice method aliasing and we 
didn't by the way? Hmm... maybe excessive aliasing isn't Pythonic).

*However* I'd just like to clarify the use of the double underscore 
prefix on class member names.

The issue states:

"there's a class in formv8.py that has named members such as 
"self._button1". I think what was actually intended here was 
"self.__button1" to make button1 a pseudo-private member. We need to fix 
this so new Python developers don't get confused"

Using a single underscore prefix is the *correct* way to indicate that a 
member is private in Python. The purpose of the double underscore name 
mangling is actually an admitted hack to avoid name collisions in 
inheritance - not to provide private members.

(Today's lesson is *never* use double underscore prefix member names 
unless you really have to - and even then you or someone else will still 
regret it. :-) That's all - nit-pick over.

Michael

-- 
http://www.ironpythoninaction.com/




More information about the Ironpython-users mailing list