dict view to list

Miles semanticist at gmail.com
Fri Mar 27 12:59:01 EDT 2009


On Fri, Mar 27, 2009 at 9:58 AM, Aaron Brady wrote:
> The suggestion is entirely a "look and feel" observation.  In an
> interactive session, to examine the contents of a dictionary I've just
> created, I need to type list(_), and lose the previous return value.
> It's a better for my <anecdote> train of thought too.

Versus _.tolist(), which would also overwrite the previous return value?

> I don't necessarily advocate that every collection and iterator should
> grow one, though I don't really have the case for a special case for
> dict views.  OTOH, I find three 'tolist' methods in the standard
> library: array, memoryview, and parser.ST.  It could offer the same as
> they do.

array has had that method since before Python v1.0. memoryview, for
whatever reason, is not iterable; parser.ST is also not, since it
doesn't convert to a flat sequence but rather a list tree.  I don't
see the special case for dict views, at all.

-Miles



More information about the Python-list mailing list