Very, Very Green Python User
hancock at anansispaceworks.com
Tue Mar 14 02:37:46 CET 2006
On 12 Mar 2006 17:58:43 -0800
hanumizzle at gmail.com wrote:
> Double-underscore methods are rewritten with the class
> name? That's an ugly hack, but remember I'm coming from
> Perl. If the language doesn't pull many other hijinks,
> that's OK.
This is GvR's way of saying "do not use double-underscore
You shouldn't ever see the mangled _<classname>__<method>
form, unless you've been very, very naughty.
And if you have been, well, we promise not to tell anybody,
but it's Your Problem [TM].
Seriously, truly private methods are generally not something
you want to mess with in Python. Quite frequently, people
with a C++ or Java background come here and ask for them. A
Frequently Repeated Thread ensues:
0) I want private methods in Python
1) you don't need 'em
2) C++ and Java have 'em and the book says you have to
have 'em, or you aren't doin' OOP
3) total hogwash -- I can use compiler directives to
defeat C++/Java "private" variables anyday, so it
doesn't accomplish anything that isn't easier to
do by putting "__" in front of it to tell the client
programmer not to use it.
Then we all go back to coding.
Cheers and good luck with your project, ;-)
Terry Hancock (hancock at AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com
More information about the Python-list