running an existing script

Ethan Furman ethan at stoneleaf.us
Tue Jun 21 14:32:59 EDT 2011


Adam Chapman wrote:
> Hi,

Howdy!

> I'm trying to put together a lot of pieces of source code in matlab,
> java, perl and python.

[snippety]

> Basically I just want to run a single script from the python command
> window. Once I know how to do that I can be off on my way to perform
> the matlab interfacing.
> 
> there is an example of the command I need in the python prompt at
> http://jboost.sourceforge.net/doc.html#cv .

That looks like a shell prompt, not a Python prompt

> however, I can't seem to run the python script by typing the command
> on that link in the python prompt.
> 
> Can I please ask how to set the current duirectory in python?

nfold.py is a python script -- you can't just type in the name once 
inside python and have it work.  It would require something like

--> import os
--> os.chdir('path/to/nfold.py') # don't include nfold.py ;)
--> import nfold
--> import sys
--> sys.argv = ["--folds=5", "--data=spambase.data",
... "--spec=spambase.spec", "--rounds=500", "--tree=ADD_ALL",
... "--generate" ]
...
--> nfold.main()  # assuming it has a main function that can be called
                   # in this manner

and that probably won't work.  What you probably want to do is execute 
the command "python /path/to/nfold.py --fold=5 ..." (include the 
nfold.py this time ).  I have no idea how to do that from Matlab.

Good luck!

~Ethan~



More information about the Python-list mailing list