Chris Angelico <ros...@gmail.com>: > On Thu, Mar 31, 2016 at 10:22 PM, Antoon Pardon > <antoon.par...@rece.vub.ac.be> wrote: > Okay. I'll put a slightly different position: Prove that your proposal > is worth discussing by actually giving us an example that we can > discuss.
Sorry for missing most of the arguments here, but if you are talking about treating lists as special cases of dicts, I have occasionally instinctively wanted something like this: >>> fields = [ "x", "y", "z" ] >>> selector = (1, 1, 0) >>> list(map(fields.get, selector)) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'list' object has no attribute 'get' analogously with: >>> field_dict = { 0: "x", 1: "y", 2: "z" } >>> list(map(field_dict.get, selector)) ['y', 'y', 'x'] Or course, I could: >>> list(map(fields.__getitem__, selector)) ['y', 'y', 'x'] but that would abuse a dunder method. So I will need to: >>> list(map(lambda i: fields[i], selector)) ['y', 'y', 'x'] or (most likely): >>> new_fields = [] >>> for i in selector: ... new_fields.append(fields[i]) ... >>> new_fields ['y', 'y', 'x'] This tiny problem of mine could be remedied by adding a get method to lists. Marko -- https://mail.python.org/mailman/listinfo/python-list