Hide module function definitions

R

Raymond Tinsel

Hello all,

I know this must be a newbie question, but I haven't found the solution in
the tutorials I have read.

For a dSPACE/Controldesk application I am defining several of my own
modules.
In those modules I also have function definitions of functions I only use in
that module.
Is it possible to hide these functions when somebody would use "import
mymodule"?

Thanks in advance!

- Raymond

P.S.: Any links to usefull documentation regarding Python (or Python for
dSPACE in specific) would also be greatly appreciated!
 
J

Jean Brouwers

There are two options:

1) Explicitly list the functions, classes, etc. to be exported by the
module in a list called __all__ inside the module.

2) Start the names of functions, classes, etc. private to the module
with an underscore character.

/Jean Brouwers
ProphICy Semiconductor, Inc.
 
A

A. Lloyd Flanagan

Raymond Tinsel said:
In those modules I also have function definitions of functions I only use in
that module.
Is it possible to hide these functions when somebody would use "import
mymodule"?

If you start the function name with an underscore, python won't import
it. Also, you can define the special variable __all__.

See http://docs.python.org/ref/import.html.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top