euglug.org

[Think] sys.path question (Pythonwin)

작성자

카테고리:



Bryan Kane (op)Tue May 18 20:54:02 PDT 2004

Thanks for all the very helpful replies.  I'll have to try it monday.

bryan

On Fri, 2003-03-14 at 14:14, Horst wrote:
> Chris has sketched out two ways in class:
> 	http://www.registerguard.com/cmeyers/class/week3/1.html
> 
> A) Using *.pth files
> --------------------
> The 'Python Library Reference' (docs of package)
> 3.27 site -- Site-specific configuration hook
> expands on the .pth approach.
> 
> I am not sure if that's the 'official' way, but if a file
> .../sitepackages/myprojects.pth
> contains
> 	C:/TEMP/projectA
> 	C:/TEMP/projectB
> and a file
> 	C:/TEMP/projectA/doit.py
> exists you can directly write
> 	import doit
> Note 1) path names in *.pth don't require backslash under Win.
> Note 2) the process is intelligent enough to not add directories to
> sys.path that don't exist.
> 
> B) .../sitepackages and your own 'packages'
> ---------------------------------------
> If you don't want to clutter up .../sitepackages and use 'packages'
> (sub-directories) like
> 	.../sitepackages/myutils/
> you want to have a file
> 	.../sitepackages/myutils/__init__.py
> in there. If package 'myutils' is just a container for unrelated modules
> the __init__.py  can exist of just one comment like
> 	# Dummy file to make this directory a package.
> 
> Then you need to pay attention to the package path: 
> 	from myutils import mycooltool
> or use the package.module notation
> 
> But Chris also had an example in that link above.
> 
>  - Horst
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> On 13 Mar 2003, Bryan Kane (op) wrote:
> 
> > Besides tinkering with python on my linux box here at home, I've started using it at work quite a bit.  I use Pythonwin there because I have a win2000 box.
> > 
> > I created a directory to hold my scripts.  I do the dir.path.append('...') command to include my directory in the system path.  But when I shut down the Pythonwin application and restart it, it doesn't show my new directory in the sys.path.  Is there something I'm missing?  How can I do sys.path.append('') and have it stick?
> > 
> > bryan
> > 
> > 
> > -- 
> > Bryan Kane (op) <r_bryan_kane at operamail.com>
> > 
> > _______________________________________________
> > Think mailing list
> > Think at zoneverte.org
> > http://mail.zoneverte.org/cgi-bin/listinfo/think
> > 
> 
> _______________________________________________
> Think mailing list
> Think at zoneverte.org
> http://mail.zoneverte.org/cgi-bin/listinfo/think
-- 
Bryan Kane <r_bryan_kane at myrealbox.com>
-- 
Bryan Kane (op) <r_bryan_kane at operamail.com>

_______________________________________________
Think mailing list
Think at zoneverte.org
http://mail.zoneverte.org/cgi-bin/listinfo/think