Scott David Daniels <[EMAIL PROTECTED]> wrote: >> To quote a poster at http://www.thescripts.com/forum/thread22741.html, >> "While we are at it, I also don't understand why sequences can't be >> used as indices. Why not, say, l[[2,3]] or l[(2, 3)]? Why a special >> slice concept? " Isn't that unpythonic? > > Right now, after: > > which_corner = {} > corner = {} > for n, position in enumerate([(1,1), (1,5), (3,5), (3,1)]): > corner[n] = position > which_corner[position] = n > > which_corner[1,5] returns 1 > > I would hate to have to know whether which_corner is a dictionary > or a list before I can decide whether this is iteration. >
Quite so, tuples are currently a valid and indeed commonly used type for subscripts, so if there was going to be special treatment it would have to be for lists only and not sequences in general. Alternatively, and more pythonically (explicit is better than implicit), we could have a special syntax to indicate that we want to use each element of the sequence as a separate subscript. I'd like to propose that the special syntax be: [s[y] for y in x] Now someone go and fire up the time machine. -- http://mail.python.org/mailman/listinfo/python-list