script vs inneractive

A

Alex Pavluck

I am a little confused because I write most of my programs in a script
editor but not all the code executes unless I run it from the
inneractive shell. Am I doing something wrong? A good example is
"return 1" in a script returns nothing where as in the inneractive
shell it will return 1 or true.
 
V

vbgunz

the interactive shell will immediatly show the result of an expression
without you having to explicitly print the result. In all text editor,
you will have to print the result if you wish to see it.
 
D

Dennis Lee Bieber

I am a little confused because I write most of my programs in a script
editor but not all the code executes unless I run it from the
inneractive shell. Am I doing something wrong? A good example is
"return 1" in a script returns nothing where as in the inneractive
shell it will return 1 or true.

An interpreter shell also shows you the result of expressions, like
a calculator...

4 + 5

will display 9.

This is simply a convenience feature. Formal scripts/programs
display only what has been commanded (print statement, sys.stdout.write,
etc.).

If that "return 1" is the last line in the program, at the most it
will be treated as a return code to the OS signaling that the program
succeeded or failed. I'm not really sure how Python handles a return
from main program.

--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
R

Robert Kern

Dennis said:
If that "return 1" is the last line in the program, at the most it
will be treated as a return code to the OS signaling that the program
succeeded or failed. I'm not really sure how Python handles a return
from main program.

It's a syntax error.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 

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
474,298
Messages
2,571,542
Members
48,282
Latest member
PrincessX3

Latest Threads

Top