Preventing direct access to a class

Daniel Klein danielk at aracnet.com
Sun Feb 4 16:50:57 EST 2001


On 4 Feb 2001 12:58:32 -0800, aahz at panix.com (Aahz Maruch) wrote:

>In article <dc4r7t41dchrbrdabst1ung9mop3u4dnoj at 4ax.com>,
>Daniel Klein  <danielk at aracnet.com> wrote:
>>
>>I have a situation where I need to prevent direct access to a class. 
>
>BTW, the standard Python idiom for declaring this is to precede the
>class name with a single underscore (see threading.py for a real
>example):
>
>class _foo:
>    pass

Yes, I see. But this only prevents access to class A if the user does
'from/import'.

Thanks,
Dan



More information about the Python-list mailing list