Re: How do I organize my Python application code?

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

    Re: How do I organize my Python application code?

    Dudeja, Rajat wrote:
    And my problem is that I don't have an understanding of how the code in
    Python is generally organized, in case my code spans multiple files,
    modules, etc. I've been using C/C++ althrough my life on Linux and
    Visaul Studio, so the way their code is organized in a group of header
    files, source files, etc, I'm looking for a similar way in Python way or
    an approach to organize my python GUI application code?
    A Python program consists of a script file (the py file you run to start
    the program), and usually one or more additional module files (py files
    that you import). The latter can be organized in packages, where
    appropriate. There's also a search path (sys.path) that you can modify
    in various ways (including from within the program) if you want to fetch
    modules from different locations.

    That's all there is; there's no header files or declaration files or
    explicitly maintained object files etc; the program itself is just a
    bunch of Python files.

    To learn more about this, the "modules" section in the tutorial is a
    good start:



    Looking at the structure of a few existing projects might also be helpful.

    </F>

  • Ken Starks

    #2
    Re: How do I organize my Python application code?

    Fredrik Lundh wrote:
    Dudeja, Rajat wrote:
    >
    >And my problem is that I don't have an understanding of how the code in
    >Python is generally organized, in case my code spans multiple files,
    >modules, etc. I've been using C/C++ althrough my life on Linux and
    >Visaul Studio, so the way their code is organized in a group of header
    >files, source files, etc, I'm looking for a similar way in Python way or
    >an approach to organize my python GUI application code?
    >
    A Python program consists of a script file (the py file you run to start
    the program), and usually one or more additional module files (py files
    that you import). The latter can be organized in packages, where
    appropriate. There's also a search path (sys.path) that you can modify
    in various ways (including from within the program) if you want to fetch
    modules from different locations.
    >
    That's all there is; there's no header files or declaration files or
    explicitly maintained object files etc; the program itself is just a
    bunch of Python files.
    >
    To learn more about this, the "modules" section in the tutorial is a
    good start:
    >

    >
    Looking at the structure of a few existing projects might also be helpful.
    >
    </F>
    >
    I would simply add that if your python script produces one or
    more output files (for example a text or graphic file) you
    might want to have an 'output' directory in your project.

    Some people use a 'src' directory, but that is not nearly as
    neccessary as in a complied language.

    In Eclipse, if you do produce output files, make them
    auto-refresh.

    Comment

    • Dudeja, Rajat

      #3
      RE: How do I organize my Python application code?


      >>Fredrik Lundh wrote:
      >That's all there is; there's no header files or declaration files or
      >explicitly maintained object files etc; the program itself is just a
      >bunch of Python files.
      >I would simply add that if your python script produces one or more
      output files (for example a text or graphic file)
      >you might want to have an 'output' directory in your project.
      >Some people use a 'src' directory, but that is not nearly as neccessary
      as in a complied language.

      Thanks Ken and Fredrik for your direction.

      Cheers,
      Rajat

      Notice: This e-mail is intended solely for use of the individual or entity to which it is addressed and may contain information that is proprietary, privileged, company confidential and/or exempt from disclosure under applicable law. If the reader is not the intended recipient or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If this communication has been transmitted from a U.S.. location it may also contain data subject to the International Traffic inArms Regulations or U.S. Export Administration Regulations and cannot be disseminated, distributed or copied to foreign nationals, residing in the U.S. or abroad, without the prior approval of the U.S. Department of State orappropriate export licensing authority. If you have received this communication in error, please notify the sender by reply e-mail or collect telephone call and delete or destroy all copies of this e-mail message, any physical copies made of this e-mail message and/or any file attachment(s).


      Comment

      Working...