modules in diff. file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JyotiC

    #1

    modules in diff. file

    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(globa l) 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

  • Calvin Spealman

    #2
    Re: modules in diff. file

    On 18 Sep 2006 00:19:20 -0700, JyotiC <jyoti.chhabra@ gmail.comwrote:
    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(globa l) 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

    Comment

    Working...