Having lots of fun passing parameters ... help!

Discussion in 'Python' started by DAC, Jun 18, 2007.

  1. DAC

    DAC Guest

    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.
     
    DAC, Jun 18, 2007
    #1
    1. Advertisements

  2. 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
     
    Diez B. Roggisch, Jun 18, 2007
    #2
    1. Advertisements

  3. DAC

    DAC Guest

    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.
     
    DAC, Jun 18, 2007
    #3
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.