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. > > By 'arrays' do you mean lists? tuples? > > I'm not sure how you'd ever find lists & dictionaries similar... > > >>> alist > [1, 2, 3] > >>> adict > > {'a': 1, 'c': 3, 'b': 2} > > One is a sequence, with convenience functions for treating it like a > stack or a queue. > The other is a mapping between keys and pairs.
You could argue that lists are also a mapping between keys and pairs, with the constraint that the keys have to be the integers from 0 to len(x)-1. That is, ['a', 'b', 'c'] is like {0: 'a', 1: 'b', 2: 'c'}, at least as far as the [] operator and the len function are concerned. -- http://mail.python.org/mailman/listinfo/python-list