Running scripts from shell / IDLE in windows

Discussion in 'Python' started by s71murfy, May 1, 2014.

  1. s71murfy

    s71murfy Guest

    Hi:

    I am trying to run the simple helloworld script from the IDLE shell. I want to pass it arguments. Please can you give me the syntax to do it?

    Thanks, Sam
     
    s71murfy, May 1, 2014
    #1
    1. Advertising

  2. On 5/1/14 10:34 AM, s71murfy wrote:

    >
    > I am trying to run the simple helloworld script from the IDLE shell. I want to pass it arguments. Please can you give me the syntax to do it?
    >


    There are several ways to do this, depending on your preferences and
    goals. Is the helloworld script the tk version? In which case have the
    script put up input dialog boxes...

    The python docs pages are very clear about input parameter i/o and may
    give you some help, if you're building a script that you want to launch
    from a terminal, or startup...

    What I do with my IDLE scripts is embed to embed a Main function (or
    call it Hello(). So, I import hello, then call hello.Main(parms). or,
    hello.Hello(parms)

    example

    ====file hello.py===

    def Hello(parms list):
    whatever
    whatever

    ====================


    From IDLE:

    import hello

    hello.Hello([1, 2, 3, 4])




    marcus
     
    Mark H Harris, May 1, 2014
    #2
    1. Advertising

  3. On 5/1/14 11:02 AM, Mark H Harris wrote:
    > ====file hello.py===
    >
    > def Hello(parms list):
    > whatever
    > whatever
    >
    > ====================
    >
    >
    > From IDLE:
    >
    > import hello
    >
    > hello.Hello([1, 2, 3, 4])


    Sorry, almost forgot, if you 'run' the module hello.py (with the IDLE
    run dropdown) then the 'hello' name will not be in the namespace... just
    enter:

    Hello(parms)

    Here is another example:

    ===hello.py===

    def Hello(myname):
    out = "hello, " + str(myname)
    print(out)

    ==============


    import hello
    hello.Hello("mark")

    hello, mark
     
    Mark H Harris, May 1, 2014
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vinay
    Replies:
    2
    Views:
    4,025
    =?ISO-8859-2?Q?Dra=BEen_Gemi=E6?=
    Jul 28, 2006
  2. ryan
    Replies:
    0
    Views:
    256
  3. Forrest Sheng Bao
    Replies:
    4
    Views:
    4,427
    Michael
    Nov 9, 2009
  4. Replies:
    0
    Views:
    201
  5. eggie5

    Running shell scripts

    eggie5, Sep 26, 2007, in forum: Ruby
    Replies:
    6
    Views:
    161
    Une BĂ©vue
    Sep 26, 2007
Loading...

Share This Page