why in returns values for array and keys for dictionary

++imanshu himanshu.garg at gmail.com
Tue Aug 26 11:04:21 CEST 2008


On Aug 26, 11:52 am, Erik Max Francis <m... at alcyone.com> 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 keys makes far more sense, since that's how
> the dictionary data structure works.  If you're doing this an awful lot
> -- whether testing for inclusion or iterating -- then you're probably
> using the wrong data structure.

Thanks for the detailed replies. Python seems to be taking the
pragmatic approach here instead of the pure one. And yes it makes more
sense.

Thanks,
++imanshu

>
> --
> Erik Max Francis && m... at alcyone.com &&http://www.alcyone.com/max/
>   San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
>    Well I have been puppetized / Oh how I have compromised
>     -- Lamya




More information about the Python-list mailing list