Having lots of fun passing parameters ... help!

Diez B. Roggisch deets at nospam.web.de
Mon Jun 18 15:57:28 CEST 2007


DAC wrote:

> I've defined a single method in Python using:
> 
> def funcAdjacents(inputWord, outputFile):
>    ...
>    lots of boring stuff
>    ...
> 
> 
> and then called it using:
> 
> funcAdjacents("SampleWord","outputFile.file")
> 
> Which works OK in Python - I get the results I want.  But what I'm
> trying to do is get inputWord and outputFile to be parameters are
> passed on the command line, e.g.
> 
> C:\Python\>  myScript.py "SampleWord" "outputFile.file"
> 
> And just to add to the fun, once I've reached this stage I would like
> to either a) be able to execute this .py file from a HTML environment
> or b) execute this file as a .exe and embed into HTML (which I can
> do).

You get the parameters to a script executed at the shell using

import sys
print sys.argv

or in your case

funcAdjacents(*sys.argv[1:])

Executing this from HTML requires the usage of CGI. But without further
details what you really are after here and what your webenvironment is, we
won't be able to help you.

Diez



More information about the Python-list mailing list