On Mon, 25 Aug 2008 19:57:06 -0700, alex23 wrote: > On Aug 26, 10:49 am, "++imanshu" <[EMAIL PROTECTED]> wrote: >> Wouldn't it be nicer to have 'in' return values (or keys) for >> both >> arrays and dictionaries. Arrays and Dictionaries looked so similar in >> Python until I learned this difference. > > […] > > In both cases, 'in' returns a boolean indicating the existence of an > item in the list, or a key in the dict. I'm not sure why you'd need it > to return the item you're checking for the existence of, as you'd have > to have that item before you could do the check. > > Have I missed what you're asking for here? Could you provide a > pseudocode example to demonstrate what you mean?
The OP isn't talking about the ``in`` operator but ``in`` as part of ``for … in …``. So it's actually the question why ``list(a_dict)`` doesn't return a list of values but a list of keys. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list