[Grok-dev] need advice on testing

Uli Fouquet uli at gnufix.de
Mon May 26 09:48:48 EDT 2008


Brandon Craig Rhodes wrote:
> "Peter Bengtsson" <peter at fry-it.com> writes:
> 
> >>>> pprint(sorted(d.items()))
> > [('age', 28),
> >  ('name', 'peter'),
> >  ('name_of_something', 'Foo'),
> >  ('this', 'is really long')]
> >
> > That way the order is guaranteed.
> 
> I think that "pprint" already sorts.

Not with Python 2.4 and if the printed object is too short::

  $ python
  Python 2.4.3 (#2, Mar  7 2008, 01:58:20)
  >>> a = dict(foo='bar', bar='baz')
  >>> from pprint import pprint
  >>> pprint(a)
  {'foo': 'bar', 'bar': 'baz'}
  >>> sorted(a.items())
  [('bar', 'baz'), ('foo', 'bar')]
  >>> pprint(a, width=5)
  {'bar': 'baz',
   'foo': 'bar'}

Kind regards,

-- 
Uli

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20080526/6a8ecce1/attachment.bin


More information about the Grok-dev mailing list