help with calling a static method in a private class
Bruno Desthuilliers
bruno.42.desthuilliers at websiteburo.invalid
Tue Sep 14 11:34:11 EDT 2010
Diez B. Roggisch a écrit :
> lallous <lallous at lgwm.org> writes:
>
>> How can I keep the class private and have the following work:
>>
>> [code]
>> class __internal_class(object):
>> @staticmethod
>> def meth1(s):
>> print "meth1:", s
>>
>> @staticmethod
>> def meth2(s):
>> print "meth2:",
>> __internal_class.meth1(s)
>>
>> x = __internal_class()
>>
>> x.meth2('sdf')
>> [/code]
>
> By not using a double underscore. It is effectless on classes anyway
> (they are not hidden because of that).
<OP>
FWIW, if what you want is to mark the class as being implementation (ie:
not part of your module's API), just prefix it with a single underscore.
</OP>
>
> And additionally, but simply not using staticmethods at all.
+1
More information about the Python-list
mailing list