[Tutor] HI, #Include like in python
john at fouhy.net
Fri Mar 20 06:32:34 CET 2009
2009/3/20 andré palma <andrefsp at gmail.com>:
> Hi \o
> I'm asking if there is any #include( C) like or any include('File.php')
> (php) like in python.
> I have 2 files: "usbconnection.py" and "listen.py", And i want to use some
> classes avaiable in "listen.py" on my main file "usbconnection.py". I've
> tryed to do __import__("listen.py") but obviously it gave me an error...
> "ImportError: No module named /home/andrefsp/projects/sigre/listen.py"
> So, if anybody knows how to do an include in python please reply me =)
Drop the .py. Just type:
You can use the __import__ function if you want, but generally you
want the import statement as above. The equivalent to 'import listen'
listen = __import__('listen')
See the tutorial here: http://docs.python.org/tutorial/modules.html
More information about the Tutor