function v. method

Antoon Pardon apardon at forel.vub.ac.be
Sun Jul 23 04:32:47 EDT 2006


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



More information about the Python-list mailing list