[Idle-dev] IDLE, ps2, and doctest

Paul M p.magwene at snet.net
Tue Oct 21 13:45:48 EDT 2003


[also posted to comp.lang.python]

Pythoneers,

IDLE doesn't use the ps2 prompt ("..." in the command line interpreter) 
because it supports multiline editing.  This issue has been discussed 
before, for example see Guido's explanation in this thread:

http://mail.python.org/pipermail/idle-dev/2002-February/000863.html

Unfortunately the lack of the ps2 prompt makes IDLE inappropriate for 
writing multi-line routines that can be used in doctest readable docstrings:

As an example, doctest want's something like this:

 >>> for each in cuppertri:
...     if each >= 0.0:
...             ct += 1
...
 >>>

Whereas IDLE gives this:

 >>> for each in cuppertri:
     if each >= 0.0:
         ct += 1


 >>>

Doctest kept failing on text I cut-and-pasted from IDLE and it took me a 
good 15 minutes to figure out what was going on.

Has anybody else run into this problem?  The "solution" of course is to 
revert to the command line when including examples in docstrings, but 
then you lose all the convenience of the IDLE environment....

Would it be possible to have the option of including the ps2 prompt in 
IDLE?  Alternately, can anybody think of a clever way to get doctest to 
recognize text pasted from IDLE (I've looked at the doctest.py source 
myself but wasn't able to come up with a non-ugly solution).

Thanks,
Paul Magwene





More information about the IDLE-dev mailing list