![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
|
Include a file?
How do you import a file you wrote, not an installed module, in Python (similar to PHP's include statement)?
|
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
The "import" statement searches for modules in the same directory (and sub-directories) of the executed script, as well as in the main Python library directory.
If I have two files called script.py and library.py sitting in the same directory, then I can import library.py by writing the following in script.py: import library |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Jun 2006
Location: at my computer desk
Posts: 138
Rep Power: 3
![]() |
wow thats easy, python seems like easy syntax
|
|
|
|
|
|
#4 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
That said, Python does have a nicely graded learning curve ![]() |
|
|
|
|
|
|
#5 |
|
Programmer
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 3
![]() |
Vb uses Imports also
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|