Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > Python

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-23-2011, 02:49 AM   PM User | #1
Apothem
Regular Coder

 
Apothem's Avatar
 
Join Date: Mar 2008
Posts: 380
Thanks: 36
Thanked 25 Times in 25 Posts
Apothem is an unknown quantity at this point
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?
Apothem is offline   Reply With Quote
Old 02-23-2011, 06:47 PM   PM User | #2
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by Apothem View Post
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
oesxyl is offline   Reply With Quote
Old 02-23-2011, 10:34 PM   PM User | #3
Apothem
Regular Coder

 
Apothem's Avatar
 
Join Date: Mar 2008
Posts: 380
Thanks: 36
Thanked 25 Times in 25 Posts
Apothem is an unknown quantity at this point
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')?
Apothem is offline   Reply With Quote
Old 02-23-2011, 11:47 PM   PM User | #4
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by Apothem View Post
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
oesxyl is offline   Reply With Quote
Users who have thanked oesxyl for this post:
Apothem (02-24-2011)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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


All times are GMT +1. The time now is 03:36 PM.


Advertisement
Log in to turn off these ads.