Running scripts from shell / IDLE in windows

S

s71murfy

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
 
M

Mark H Harris

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
 
M

Mark H Harris

====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
 

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

Similar Threads


Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top