Python windows interactive.

Steve Holden steve at
Tue Oct 31 03:42:23 CET 2006

notejam wrote:
> Thanks everyone for the help.   I got a simple two line program to work
> from a text file.
> Can not figure out how to write more than one line in interpreter mode.
>  Is that all interpreter is good for, testing one liners?  I have it
> run the program everytime I hit return, and can not figure out how to
> enter multiple lines of code.  I can do multiple lines in text file, so
> no problem, but I am jsut wondering can a program with 2 or more lines
> be wrote from the interpreter mode?
The interactive interpreter is mostly for experimentation, but of course 
its advantage is that you can test out complex functionality imported 
from modules and packages. Want to know what's on the Google home page?

  >>> import urllib
  >>> f = urllib.urlopen("")
  >>> data =
  >>> print data
<html><head><meta http-equiv="content-type" content="text/html; 
function sf(){document.f.q.focus();}
// -->
</head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b 
alink=#ff0000 onload=sf() topmargin=3 marginheight=3><center><div 
align=right nowrap style="padding-bottom:4px" width=100%><font size=-1> ...
<font size=-2>&copy;2006 Google</font></p></center></body>

You can also define funcitons and classes, and write multi-line 
statements interactively once you learn the conventions, but once 
functionality "hardens" into something of five lines or more that you 
want to experiment with you will find it's usually easier to edit a 
script or program in a text file and run it. This is even more the case 
when you start to use "test-driven development", something we shoudl all 
aspire to.

Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd
Skype: holdenweb
Recent Ramblings

More information about the Python-list mailing list