Writing "pythonish" code

Neil Cerutti horpner at yahoo.com
Fri Feb 2 09:41:14 EST 2007


On 2007-02-02, Toby A Inkster <usenet200701 at tobyinkster.co.uk> wrote:
> Mizipzor wrote:
>> One thing is that in c++ im used to have private members in
>> classes and no member is altered except through the public
>> functions of the class.
>
> By convention, class members starting with a single underscore
> are considered private. 

An important consideration is that this convention is simply a
lower level of enforcement than C++ provides. Private members in
C++ are accessible if you use pointers.

> Class members starting with a double underscore are "mangled"
> which makes it more difficult for other code (even subclasses!)
> to access the member. Difficult though -- not impossible.

I think it's best to never use such names in new code. Python's
mangling is troubled, since it uses unqualified names in the
mangle, resulting in ambiguity.

-- 
Neil Cerutti
Ushers will eat latecomers. --Church Bulletin Blooper



More information about the Python-list mailing list