modules in diff. file

J

JyotiC

hi,

i have a prog. and i want diving the code in different files.
there will be one mail file which will call modules or
variables(global) from differnet files
how can i do this.
code is very big and i it's getting difficult to manage in same file.

thanx in advance
 
C

Calvin Spealman

hi,

i have a prog. and i want diving the code in different files.
there will be one mail file which will call modules or
variables(global) from differnet files
how can i do this.
code is very big and i it's getting difficult to manage in same file.

thanx in advance

All of this is covered in any good Python tutorial, including the
official documentation. Simply move code you want to seperate into
their own python files. They will become importable modules, so foo.py
can be accessed with `import foo` from another module. Now, be careful
because you can't circularly import the modules. That means that if
you have module foo and module bar, they can't both import each other.
You'll have to take that into consideration when you seperate the code
into these modules. you can usually break up a moderately sized
project such that one main module imports all the others, and none of
them need to know about one another.

Python Tutorial - Modules
http://docs.python.org/tut/node8.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
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top