Making immutable instances

Antoon Pardon apardon at forel.vub.ac.be
Mon Nov 28 10:25:51 CET 2005


Op 2005-11-26, Steven D'Aprano schreef <steve at REMOVETHIScyber.com.au>:
> On Thu, 24 Nov 2005 12:55:07 +0000, Antoon Pardon wrote:
>
>> Suppose I have the following code.
>> 
>> from module import __take_care__
>> 
>> __private_detail__ = ...
>> 
>> I now have two variable that are flaged the same way, but they are not.
>
> No, you have two names written using a poor naming convention.

Well if it is a poor naming convention, why react to me, and not to
Mike who was defending this poor naming convention?

> __name__ should be used only for Python's special methods.
>
>> __take_care__ is a private variable from an other module which I should
>> use with extreme care not to break the other package.
>
> Python doesn't do any special treatment of __name or __name__ from
> modules. The only information hiding techniques Python enforces are that
> module._name (single leading underscore) is not imported by "from module
> import *", and class.__name (double leading underscore) is mangled to
> class._Class__name.

We were not talkin about special treatment by python. We were talking
about conventions to communicate purpose to other readers of the
software.

>> It are other modules that should take special care if they
>> should choose to import this variable.
>
> I'm not sure what the difference is. If there is a difference, why are you
> using the same naming convention for different sorts of names ("private
> module variable" and "private module data"). If there is no difference, I
> don't understand the point of your example.

Well it seems you didn't seem to understand the point of my answer.
Maybe you should first reread the article I responded too.

-- 
Antoon Pardon



More information about the Python-list mailing list