I am writing a sizable side project in python and I have got a module which implements all database access with only functions declared within the module.I was wondering if there is anyway to declare functions in the module as public so that python knows that these are the only functions that should be used from outside the module.
-
You don't need: Python allows use of every part of everything from everywhere ;) Perhaps you meant to ask the reverse question, i.e. how to make stuff inaccesible from the outside? Not that it would be possible...user395760– user3957602011-12-31 16:44:35 +00:00Commented Dec 31, 2011 at 16:44
Add a comment
|
3 Answers
Don't preface them with _ (underscore).
According to PEP 8 -- Style Guide for Python Code:
public attributes should have no leading underscores
Comments
Declare a module-level variable named __all__. This is a tuple of strings and will be the only symbols imported by from module import * and the only names that appear in help(module).
2 Comments
Ignacio Vazquez-Abrams
But that won't actually affect the public interface of the module.
kindall
This is the closest you get in Python: the developer telling you "here, use these."