How to make a module function visible only inside the module?

beginner zyzhu2000 at gmail.com
Sun Aug 19 02:45:34 CEST 2007


Hi Everyone,

Is there any equivalent version of C's static function in Python. I
know I can make a class function private by starting a function name
with two underscores, but it does not work with module functions.

For exmaple, __func1 is still visible outside the module.

mymodule.py
"""my module""

def __func1():
    print "Hello"



main.py
import mymodule

mymodule.__func1()

Thanks,
Geoffrey




More information about the Python-list mailing list