On Monday, January 27, 2020 at 2:01:04 PM UTC-8, Nils Bruin wrote:
>
> For 2) there are different possibilities.
> a) Something like sorted(D.iteritems()) works, but it means the doctest
> now displays a list of tuples rather than something that looks like a dict:
> not a problem for "TESTS:" but less than desirable for "EXAMPLES:".
>
>
In Py3.7 we can use the insertion order preservation to write:
dict(sorted(D.items()))
or
{k:D[k] for k in sorted(D)}
It's still a bit circuitous to write compared to just
D
but it does express the intent and prints like a dictionary (because it is
one). I'm not sure I'm in favour of it, but we should take it into account
when deciding what we do (the thread on python-devel dealing with
specifying insertion order preservation in Py7 has some lively discussion
on `pprint` and its sorting behaviour).
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sage-devel/4f63ff2e-4507-4d29-bcf5-3911b5cdef80%40googlegroups.com.