CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Python (http://www.codingforums.com/forumdisplay.php?f=46)
-   -   How do you "change" paths? (http://www.codingforums.com/showthread.php?t=219470)

Apothem 02-23-2011 02:49 AM

How do you "change" paths?
 
My webhost is using Python 2.4

Suppose I have the following directories:
Code:

public_html/subdomain_1/main.py
public_html/subdomain_2/module_1.py
public_html/subdomain_2/module_2.py

And I go to subdomain_1.mysite.com/main.py

How do I make it so that in main.py, all imports are treated as if it was in directory public_html/subdomain_2?

oesxyl 02-23-2011 06:47 PM

Quote:

Originally Posted by Apothem (Post 1057220)
My webhost is using Python 2.4

Suppose I have the following directories:
Code:

public_html/subdomain_1/main.py
public_html/subdomain_2/module_1.py
public_html/subdomain_2/module_2.py

And I go to subdomain_1.mysite.com/main.py

How do I make it so that in main.py, all imports are treated as if it was in directory public_html/subdomain_2?

example take from here http://docs.python.org/release/2.6.6...andard-modules
Code:

import sys
sys.path.append('/ufs/guido/lib/python')

best regards

Apothem 02-23-2011 10:34 PM

Well, I did not think that was the function because it had that word "append" in it.

Does it work as such:
sys.path.append('../subdomain_2')?

oesxyl 02-23-2011 11:47 PM

Quote:

Originally Posted by Apothem (Post 1057642)
Well, I did not think that was the function because it had that word "append" in it.

Does it work as such:
sys.path.append('../subdomain_2')?

yes, it work. You even didn't try to test it and is a single line of code. I'm sorry but this was my last attempt to help you.

Good luck and best regards


All times are GMT +1. The time now is 03:34 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.