Re: why in returns values for array and keys for dictionary

2008-08-26 Thread Asun Friere
On Aug 26, 10:49 am, ++imanshu [EMAIL PROTECTED] wrote: Hi, Wouldn't it be nicer to have 'in' return values (or keys) for both arrays and dictionaries. NO! When you iterate over a list (or even a array) it is the members of the list in the order they appear that is of interest. When

Re: why in returns values for array and keys for dictionary

2008-08-26 Thread Erik Max Francis
Marc 'BlackJack' Rintsch wrote: 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

Re: why in returns values for array and keys for dictionary

2008-08-26 Thread Erik Max Francis
++imanshu 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. It's because dealing with keys makes far more sense, since that's how the dictionary data

Re: why in returns values for array and keys for dictionary

2008-08-26 Thread ++imanshu
On Aug 26, 11:52 am, Erik Max Francis [EMAIL PROTECTED] wrote: ++imanshu 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. It's because dealing with

Re: why in returns values for array and keys for dictionary

2008-08-26 Thread bearophileHUGS
++imanshu: 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. D language works like you say, and it's awful. With a key you can find its value, but given only the

Re: why in returns values for array and keys for dictionary

2008-08-26 Thread Lie
On Aug 26, 4:04 pm, ++imanshu [EMAIL PROTECTED] wrote: On Aug 26, 11:52 am, Erik Max Francis [EMAIL PROTECTED] wrote: ++imanshu 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

Re: why in returns values for array and keys for dictionary

2008-08-26 Thread Terry Reedy
Lie wrote: Anyway, there is two obvious choice when dealing with dictionary looping: return the keys and return the key and value. The python designer thought... The issue of whether there should be a default iterator and if so, which of the two obvious choices should be picked, was

why in returns values for array and keys for dictionary

2008-08-25 Thread ++imanshu
Hi, 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. Thanks, ++imanshu -- http://mail.python.org/mailman/listinfo/python-list

Re: why in returns values for array and keys for dictionary

2008-08-25 Thread alex23
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. By 'arrays' do you mean lists? tuples? I'm not sure how

Re: why in returns values for array and keys for dictionary

2008-08-25 Thread alex23
On Aug 26, 12:57 pm, alex23 [EMAIL PROTECTED] wrote: By 'arrays' do you mean lists? tuples? My apologies, there actually -is- an array type in Python. I've just honestly never had any cause to use it :) I'm still not entirely sure what you would like 'in' to do, though. --

Re: why in returns values for array and keys for dictionary

2008-08-25 Thread Dan Bishop
On Aug 25, 9:57 pm, alex23 [EMAIL PROTECTED] 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.

Re: why in returns values for array and keys for dictionary

2008-08-25 Thread Marc 'BlackJack' Rintsch
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.

Re: why in returns values for array and keys for dictionary

2008-08-25 Thread alex23
On Aug 26, 2:30 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: 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. Aaaah! Cheers, Marc, that didn't