[Tutor] Doctest, object references and the use of ellipses

Tim Peters tim.peters at gmail.com
Sun Apr 2 01:42:29 CEST 2006


[Tim Peters]
>> That "should work", provided there aren't differences in whitespace
>> that are invisible to us in this medium.  For example, if, in your
>> source file, there's actually a (one or more) trailing space on your
>> line of expected output, then it would _not_ match the actual output.
>> Try adding +REPORT_NDIFF to your #doctest options; that will point out
>> all differences (including whitespace).

[Don Taylor]
> Oh, thank you!

Cool -- glad it worked!

> Yes, there was a trailing whitespace.  And yes I did read the manual
> that warned about this but I guess it did not register deep enough into
> my reptile brain (you know, the Python brain).
>
> I will try not to do this again (and I probably won't).

I'll share a secret :-)  I work on Python development, and a few times
per week I run this from the root of a Python checkout (this is on
Windows, BTW):

    python \Python24\Tools\Scripts\reindent.py -r .

reindent.py is in your distribution too.  It ensures (by rewriting
files as needed) that all .py files reachable from "." conform to core
Python's whitespace standards, which includes things like 4-space
indentation, no hard tab characters, and no trailing whitespace on any
lines.  All the .py files in a distribution are automatically kept
free of "whitespace surprises" this way.  You're allowed to run that
on your code too ;-)


More information about the Tutor mailing list