Having lots of fun passing parameters ... help!

D

DAC

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).

Has anyone got any ideas?

DAC.
 
D

Diez B. Roggisch

DAC said:
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
 
D

DAC

DAC said:
I've defined a single method in Python using:
def funcAdjacents(inputWord, outputFile):
...
lots of boring stuff
...
and then called it using:

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- Hide quoted text -

- Show quoted text -

Thanks Diez, I understand what you mean. I'm fine with the CGI aspect
of things, it was just getting those parameters across which was
difficult.

DAC.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top