Advertisement

05.22.2008 at 04:39AM PDT, ID: 23423970
[x]
Attachment Details

Python - path

Asked by craigdev in Python Scripting Language

Hi Im using Python from .NET and am getting a bit confused by the path variable.

Ideally I want to have my relevant .py files in a separate subfolder and be able to set that to wherever I like. So for instance I have a file called test.py that sits in the same folder as my .NET executable, then the following .NET code allows me to run the test script .....

            PythonEngine.Initialize()
            PythonEngine.ImportModule("test")

Imagine in this case that the path to the exe and .py folder is C:\app\app.exe and C:\app\test.py

Now if I want to move the test.py file to C:\app\pyfiles\test.py how would I change the path so Python can find it in the new folder?

PythonEngine.ImportModule("pyfiles\test") does not seem to work.

Furthermore, in the test.py file I am writing a new text file with this code: f = file(' newfile.txt', 'w') so the newfile.txt appears in whichever folder the test.py script sits in. Ideally I would like to be able to write to a folder such as C:\app\output instead of just whichever folder python is working from.








Start Free Trial
[+][-]05.22.2008 at 05:55AM PDT, ID: 21623321

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Python Scripting Language
Sign Up Now!
Solution Provided By: ramrom
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.22.2008 at 05:57AM PDT, ID: 21623338

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628