Private methods
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue Oct 9 19:51:07 EDT 2012
On Tue, 09 Oct 2012 11:08:13 -0600, Ian Kelly wrote:
> On Tue, Oct 9, 2012 at 8:08 AM, Demian Brecht <demianbrecht at gmail.com>
> wrote:
>> A single underscore semantically means private. A double underscore
>> will name mangle the function such that it's only accessible strictly
>> by name through the class that it's define in. Note that you *can*
>> still access it if you understand how name mangling works. Nothing in
>> Python is truly private.
>
> I tend to view name mangling as being more for avoiding internal
> attribute collisions in complex inheritance structures than for
> designating names as private.
Really? I tend to view name mangling as a waste of time, and complex
inheritance structures as something to avoid.
--
Steven
More information about the Python-list
mailing list