[Python-3000] Dropping the parentheses after dict.keys?

Noam Raphael noamraph at gmail.com
Thu Dec 13 10:41:50 CET 2007


2007/12/13, Guilherme Polo <ggpolo at gmail.com>:
> 2007/12/13, Noam Raphael <noamraph at gmail.com>:
> > Hello,
> >
> > Was it considered to drop the parentheses after "dict.keys()", to make
> > it "dict.keys" (that is, to make it a property instead of a method
> > with no arguments)? If it was, please forgive me - a few minutes of
> > googling didn't find it.
>
> Such thing wasn't considered, I doubt it will.

You know, that is a very well-reasoned explanation.

> >
> > I now write (another?) ordered dict, and I thought that the easiest
> > way to get the key with a given index would be "d.keys[5]". But it
> > means that d.keys is a collection of keys, not a method - and why not?
> >
>
> d.keys()[5] won't work on python 3.0 aswell because it returns a view now.
>
Let me clarify myself. I just meant to say that I think that "for x in
d.keys" looks better than "for x in d.keys()", and that if you create
a dict subclass which has ordering, "d.keys[5]" looks really better
than "d.keys()[5]".

Noam


More information about the Python-3000 mailing list