Message105191
Maybe the wording should be changed, but name mangling serves a useful
purpose. There are two definitions of "private" which seem to be a
bit conflated in this section:
* "private" as in, "this name is not part of the public API - use it
at your own risk".
* "private" as in, "I don't want someone to accidentally stomp on this
attribute name when subclassing this class".
I think it is valuable to mention both of these conventions in the
tutorial for a couple reasons:
* the tutorial is meant for people new to Python but with experience
in other programming languages
* the distinction between _a and __a is a bit subtle and not obviously
similar to privacy features present in other languages.
I work with a lot of C++ programmers who also write some Python
(sometimes a lot of Python). It's clear at times that the distinction
hasn't always sunk in. |
|
Date |
User |
Action |
Args |
2010-05-07 11:13:41 | skip.montanaro | set | recipients:
+ skip.montanaro, eric.araujo, meatballhat, LucianU, docs@python |
2010-05-07 11:13:41 | skip.montanaro | set | messageid: <1273230821.32.0.414160027863.issue8638@psf.upfronthosting.co.za> |
2010-05-07 11:13:39 | skip.montanaro | link | issue8638 messages |
2010-05-07 11:13:38 | skip.montanaro | create | |
|