Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 30th, 2006, 12:11 PM   #1
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 843
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
Include a file?

How do you import a file you wrote, not an installed module, in Python (similar to PHP's include statement)?
titaniumdecoy is offline   Reply With Quote
Old Jun 30th, 2006, 12:18 PM   #2
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
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
Arevos is offline   Reply With Quote
Old Jun 30th, 2006, 12:21 PM   #3
angry_asian
Hobbyist Programmer
 
Join Date: Jun 2006
Location: at my computer desk
Posts: 138
Rep Power: 3 angry_asian is on a distinguished road
wow thats easy, python seems like easy syntax
angry_asian is offline   Reply With Quote
Old Jun 30th, 2006, 1:45 PM   #4
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by angry_asian
wow thats easy, python seems like easy syntax
I'm hardly one to disagree, but this isn't unique to Python: C#, Java and Ruby all have similar systems.

That said, Python does have a nicely graded learning curve
Arevos is offline   Reply With Quote
Old Jun 30th, 2006, 11:02 PM   #5
Master
Programmer
 
Master's Avatar
 
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 3 Master is on a distinguished road
Vb uses Imports also
Master is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:23 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC