[TIP] dicts in doctests
barry at python.org
Wed Sep 17 19:19:45 PDT 2008
-----BEGIN PGP SIGNED MESSAGE-----
On Sep 17, 2008, at 10:15 PM, Fred Drake wrote:
> On Wed, Sep 17, 2008 at 9:52 PM, Barry Warsaw <barry at python.org>
>> Right, good point. Be careful though because I think pprint's
>> sorting is
>> broken in Python 2.4.
> With Python 2.4 and earlier, dicts for which the standard repr fit
> within the available space without being stacked did not get their
> keys sorted. Stacked displays were sorted just fine.
> One approach would be to always use the width control to force the
> stacked display. This works for all versions:
>>>> import pprint
>>>> def display(ob):
> ... pprint.pprint(ob, width=1)
Ah, I didn't know that. Thanks for the tip!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
-----END PGP SIGNATURE-----
More information about the testing-in-python