2. Re: Python interface problem with Windows (Benjamin Kaplan)

K

Kermit Rose

Today's Topics:
2. Re: Python interface problem with Windows (Benjamin Kaplan)
> Message: 2
> Date: Sat, 26 Jun 2010 16:26:47 -0700
> From: Benjamin Kaplan <[email protected]>
> To: (e-mail address removed)
> Subject: Re: Python interface problem with Windows
> Message-ID:
> <[email protected]>
> Content-Type: text/plain; charset=ISO-8859-1
> You don't need to save scripts in C:\Python26. In fact, doing so is a
> very bad idea. You should keep the libraries in one place (that would
> be C:\Python26 ) and all of your individual programs somewhere else
> (like your Documents folder) where you don't have to worry if two
> different projects have files of the same name. For security reasons,
> you don't have permission to write to the whole hard drive, just your
> home directory.




I do not know how to import code from any other directory than the
default, C:\Python26.

And how do I save the code in a different directory than the default,
c:\Python26?


Kermit Rose
 
R

rantingrick

On 6/26/2010 9:30 PM, (e-mail address removed) wrote:
I do not know how to import code from any other directory than the
default, C:\Python26.

Kermit,

There are a couple of ways to import python modules from various
places. But first create a folder somewhere (like was mentioned
earlier) to keep all your personal modules and scripts in. Now create
a file named "myconfig.pth" and throw it in your main PythonXX folder.
Any paths in this file will be added to the search path of Python
modules. Now you can import from these folders

Also so you will be aware. You can add folders to the python search
path by appending or inserting to the sys.path array.
import sys
print sys.path [...list of paths here...]
sys.path.append('path\to\some\directory\containing\script.py')
import script.py

There are other ways...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top