On 06Jul2018 01:43, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> 
wrote:
On Fri, 06 Jul 2018 09:31:50 +1000, Cameron Simpson wrote:
On 05Jul2018 17:57, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote:
I have three ways of dealing with this. Which do you prefer?

Option 4:

    >>> func(1) == {'a': 1, 'b': 2, 'c': 3}
    True

Alas, in reality func takes anything up to six arguments, at least one of
which will be a moderately long sequence requiring two lines:

   >>> func([('a', 1), ('bb', 2), ('ccc', 4), ('dddd', 8)],
   ...      ('eee', 16), ('ff', 32), ('g', 64)], ...

and the output is similarly long. So making it a one-liner isn't
generally practical.

If you're in Python 3 there's a DocTest.OutputChecker class. Maybe it's possible to subclass this in some doctest utility and use that to catch unsorted dicts?

I speak freely here, as one who hasn't tried this.

But I'm just starting with doctest myself, so I'm interested.

Cheers,
Cameron Simpson <c...@cskk.id.au>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to