[portland] Still Having List/Tuple Problems
python at dylanreinhardt.com
Thu Apr 17 07:35:26 CEST 2008
On Wed, Apr 16, 2008 at 6:09 PM, kirby urner <kirby.urner at gmail.com> wrote:
> i.e. as iterables, dictionaries already have a default "step though"
> behavior, which is to go through the keys.
> So you don't have to explicitly fire the keys() method, and doing
> so is less generic i.e. takes advantage of this being a dictionary,
> versus an iterable.
With all due respect to idiomatic Python, something important can be
lost when you refine code. Treating all iterators the same is more
general and more pleasing to the eye... but it is also less explicit
and, therefore, less readable.
Because iterables are ordinarily *ordered*, the risk here is that you
may obscure the special *non-ordered* character of a key listing.
Using .keys() might be ugly, but it is explicit and unsurprising.
More information about the Portland