[BangPypers] Re :Use of module (Include file) in Python???

venkata subramanian venkatasubramanian at gmail.com
Sat Sep 6 14:45:55 CEST 2008

Hi Deepak,
 You can do this.
 It is using the keyword called import.

 The basic syntax is
import <your_module_name_here>

 example: import RegDesc

 then, you can do RegDesc.foo(bar)

 My friend had the same problem. He read the tutorial till
 one point and missed the part where they talk about modules
 and packages. So, go ahead and make sure you covered those topics.

 Like other languages, your module should be in a 'path' called pythonpath.
 you can do import sys and then type sys.path to know the path.

 All the modules in your current directory can be imported (well,
 without going into the nittie gritties of it).

On Sat, Sep 6, 2008 at 8:03 AM, Deepak Patel <dpatel_07 at rediffmail.com> wrote:
> Hello,
> I am new to Python and need some help.
> Can someone please tell me whether I can use the Python Module like include
> file?
> Is there a way to use the "include" file in Python?
> If I try to include a file with "# include", that line is treated as
> comment.
> What is the directive to include the include file in Python?
> I have created a Python prgram, say RegDesc.py for my registers class
> definitions, for example, called as:class Reg:with all the register methods,
> like ReadReg(), WriteReg() etc.
> In the same file, I have description of various registers, like:ConfigReg =
> Reg(.....).
> Now I want to treat my RegDesc.py as include file to my other programs and
> use the Reg class methods in my other programs.
> How can I do this? Do I need to use module?
> Thanks,
> Deepak
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers

More information about the BangPypers mailing list