How do you run python scripts from other script and have their root in my root?


How do you run python scripts from other script and have their root in my root?



I have a module "B", I want to run it from a script "C", and I want to call global variables in "B", as they were in the "C" root. Another problem is if I imported sys in "B" when I run "C" it doesn't see sys

# NameError: global name 'sys' is not defined #

What shall I do?




Function parameter types in Python

1:



Best/Fastest Way to Test Python CGI locally?
When you import a module B (like import B), every line in B will be interpreted.


Simple way to encode a string according to a password?
I assume this is what you mean when you say you want to run it.


Enforce “spaces” or “tabs” only in python files?
To reference members in B's namespace, you can get them like:.
How to rename a file using Python
B.something_defined_in_B..
Access Delicious API via Yahoo ID without redirect to Yahoo authorizing page
If you wish to use sys explicitly in C, you will need to import it within C as well..
OpenType with Python [closed]


Renaming a pylons controller

2:


is it in your PYTHON_PATH?. if not, in script C's init.py.
import os, sys sys.path.append('/PATH/TO/MODULE/B') 
then, in module C.
from B import * something_defined_in_B() 



82 out of 100 based on 72 user ratings 622 reviews

@