Newbie Questions: Swithing from Perl to Python
Todd Stephens
huzzah at tampabay.rr.com
Sun Oct 26 08:42:34 EST 2003
On Sun, 26 Oct 2003 01:18:51 -0500, Geoff Gerrietts wrote:
> I think the only danger with your solution is that you're relying on the
> implicit behavior in the coerce-dictionary-to-list. When you ask a
> dictionary for its keys, it's a little clearer what you're after. In
> your example, if I didn't know already that list(myD) returned a list of
> the keys, I would hafta wonder: is it a list of keys? A list of values?
> A list of (key, value) tuples? In other words, you're sacrificing some
> readability.
To be honest, I didn't know that using list() on a dictionary returned a
list of the keys until I tried it. Judging by that, I would say that you
are correct about it sacrificing readability. I wonder if either method
has a speed advantage though.
--
Todd Stephens
More information about the Python-list
mailing list