function v. method

fuzzylollipop jarrod.roberson at gmail.com
Mon Jul 24 12:28:43 EDT 2006


Antoon Pardon wrote:
> On 2006-07-21, fuzzylollipop <jarrod.roberson at gmail.com> wrote:
> >
> > Antoon Pardon wrote:
> >
> >> Suppose I am writing my own module, I use an underscore, to
> >> mark variables which are an implementation detail for my
> >> module.
> >>
> >> Now I need to import an other module in my module and need access
> >> to an implementation variable from that module. So now I have
> >> variables with an underscore which have two different meanings:
> >
> > you don't understand what "implementation detail" means, it means it is
> > NOT part of the public API and no client code should ever use it.
> >
> > If you reference _vara in your code and it is in someone elses module
> > you don't understand YOU ARE NOT SUPPOSED TO DO THAT!
>
> Why do you assume that in my example the other module is
> not understood?
>
> >>   1) This is an implemantation detail of this module, It is the
> >>      users of my module who have to be extra carefull using it.
> >
> > Users of your module should NEVER KNOW any of the _ or __ stuff exists
> > to begin with.
> >
> >>   2) This is an implemantation detail of the other module,
> >>      I should be extra carefull using it.
> >
> > You should NEVER use it.
>
> Well that may be your view, but AFAICS it is not the view of
> the python community. Because each time some mechanism is
> proposed for real private variable, people oppose it, they
> want people to have access to what are supposed to be
> private variables.
>
> --
> Antoon Pardon

actually you are really way off base, the _ and __ convention IS the
INTENDED way of doing private and "really private" documentation of
members in Python.

I didn't make this up, it is in the official Python documentation.

You need to read my previous response for COMPREHENSION one more time.
There is LESS THAN ZERO value in having a runtime enforcement of member
access control.

Python does have ALREADY have an OFFICAL mechanism for private members,
prefix your names with _ or __. Both are ommited from autogenerated
docuementation and both are OFFICALLY not supposed to be used.




More information about the Python-list mailing list