Interactive question, change to help() in pydoc.py

Richard rmiNchOael+newsS at Pfields.utAoronto.cMa
Thu May 29 01:31:10 EDT 2003


Hello,

I've decided to use python to teach programming basics because there 
seems to be great community surrounding python in education.

Regarding the interactive interpreter, is it possible to put it into a 
mode to allow multi-line input, with a "final" execution after the last 
input line?  I'd like students to be able to type code "fragments" into 
the interpreter without it executing each line.  Right now, I'm using:

 >>> if 1:
...   print "hello, world!"
...   print "goodbye, cruel world!"
...

However, I'm teaching people with zero programming / computing 
experience, so I'd like to avoid the complication of explaining the 
requisite indentation and the "if 1:" statement.

Have I missed something in the interactive interpreter documentation (it 
seems a little sparse)?  Thoughts?

Also,

I've changed the pydoc.py module so that it uses readline.  I did this 
by changing it's input from:

request = self.input.readline()

to

request = raw_input("Help> ")

I also commented out the "self.output.write("help> ") and flush bits.

This pollutes the python readline history file, but I think it's 
preferable to have history in the help() interface (especially for 
students).  Perhaps a better solution would be to create a new instance 
of the readline object with a help only history file?  (This might also 
be nice for teachers to review the most frequently used help topics.)

help() still seems to work, are there any problems using raw_input in 
this case?  (I've only been using python for about half an hour now!)

Regards,
Richard





More information about the Python-list mailing list