LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-10-2003, 04:41 AM   #1
miknight
Member
 
Registered: Oct 2002
Location: Sydney, Australia
Distribution: Gentoo, Ubuntu, Debian
Posts: 184

Rep: Reputation: 30
Question Python - can I import my own stuff?


I was wondering if there's a way to include another python file full of functions for my script to use without having to move it into my python modules directory. I'm after a similar effect to PHP's 'include' function.

Any help would be appreciated thanks!
 
Old 06-10-2003, 07:48 AM   #2
ranger_nemo
Senior Member
 
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 46
I've recently started reading a book on Python basics... I'm sure you can import your own code just like you can standard Python modules.

Did a quick Google and came up with the page...
http://aspn.activestate.com/ASPN/Pyt...tut/node8.html

As long as you add to Python's search path, you should be able to import your own code with...

import my_program
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
python, import and execfile() cs-cam Programming 1 10-18-2005 08:47 PM
Python: Idle: ImportError: cannot import name sleep Joe Soap Linux - Newbie 1 10-01-2005 01:52 AM
which script stuff to use? --Python ruwach Programming 4 05-27-2005 10:49 AM
Import sys ?bash: import: command not found joirnange Linux - Newbie 4 12-28-2004 10:33 PM
python: import distutils fails on debian? jpbarto Linux - Software 0 01-18-2004 10:36 AM


All times are GMT -5. The time now is 06:28 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration