running an existing script

Ethan Furman ethan at stoneleaf.us
Wed Jun 22 12:35:30 EDT 2011


Adam Chapman wrote:
> On Jun 21, 9:12 pm, Adam Chapman <adamchapman1... at hotmail.co.uk>
> wrote:
>> On Jun 21, 8:00 pm, Ethan Furman <et... at stoneleaf.us> wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> Adam Chapman wrote:
>>>> Thanks Ethan
>>>> No way could I have worked that out in my state of stress!
>>>> For your second idea, would I need to type that into the python command
>>>> line interface (the one that looks like a DOS window?
>>> If you are actually in a python CLI, at the top of that screen does it
>>> say something like
>>> Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
>>> (Intel)] on win32
>>> Type "help", "copyright", "credits" or "license" for more information.
>>> ?
>>> If yes, then what I wrote earlier should actually work (I downloaded
>>> jBoost and looked at the nfold.py script).  Here it is again:
>>> --> import os
>>> --> os.chdir('path/to/nfold.py') # don't include nfold.py  ;)
>>> --> import nfold
>>> --> import sys
>>> --> sys.argv = ["nfold.py", "--folds=5", "--data=spambase.data",
>>> ... "--spec=spambase.spec", "--rounds=500", "--tree=ADD_ALL",
>>> ... "--generate" ]
>>> ...
>>> --> nfold.main()
>>> I fixed the sys.argv line from last time.
>>> Good luck!
>>> ~Ethan~
>> Thanks to both of you for your help.
>>
>> It's getting late here, I'll give it another try tomorrow
> 
> I've added the python directories to the environment variable "path"
> in my computer (http://showmedo.com/videotutorials/video?
> name=960000&fromSeriesID=96), which means I can now call python from
> the windows DOS-style command prompt.
> 
> My formatting must be wrong when calling the nfold.py script to run.
> My connad prompt call and the computer's response look like this:
> 
> C:\Users\Adam\Desktop\JBOOST\jboost-2.2\jboost-2.2\scripts>nfold.py
> nfold.py
>   File "C:\Users\Adam\Desktop\JBOOST\jboost-2.2\jboost-2.2\scripts
> \nfold.py", line 13
>     print 'Usage: nfold.py <--booster=boosttype> <--folds=number> [--
> generate | --dir=dir] [--data=file --spec=file] [--rounds=number --
> tree=treetype]'
>  
> ^
> SyntaxError: invalid syntax

Looks like you are using Python 3, but nfold is Python 2.  You're being 
tripped up by one of the non-compatible changes -- namely, print is now 
a function and so requires ().


> What I dont understand is that some of the parameters in the syntax it
> printed back are in <> brackets, and others in [] brackets.

Looking at nfold.py it seems that rounds and tree are optional, one of 
generate or dir is required, if dir is not given then data and spec must 
be, and booster and folds are required -- so I'm not really sure why 
they chose the mixture of <> and [].


Also, on the version of jBoost I downloaded there is at least one error 
on nfolds.py on line 134 -- it should be indented one more level.

Hope this helps.

~Ethan~



More information about the Python-list mailing list