consider the following pattern:
'''some module body'''
def __foo():
'''module method foo'''
pass
class Dummy(object):
@staticmethod
def bar():
__foo()
__foo() # No Error.
Dummy.bar() #NameError: Global name "_Dummy__foo" is not defined.
Why is this happening?
--
And if it's bad to name it with "__", what is the best practice in Python to make module methods available only for inner-module functions/methods?
__spam(at least two leading underscores, at most one trailing underscore) is now textually replaced with_classname__spam, whereclassnameis the current class name with leading underscore(s) stripped."