On Mon, Dec 12, 2011 at 11:17 AM, Eelco <hoogendoorn.ee...@gmail.com> wrote:
> Im not sure if I was clear on that, but I dont care what the
> constructors accept; I meant to overload on the concept the underlying
> type models. Dicts model a mapping, lists/tuples model a sequence. MI
> deriving from both these models is illegal anyway, so one can
> unambigiously overload on that trait.

False.

>>> from collections import *
>>> class Foo(Sequence, Mapping):
...     def __init__(self, items):
...         self._items = items
...     def __getitem__(self, item):
...         return self._items[item]
...     def __len__(self):
...         return len(self._items)
...
>>> foo1 = Foo(range(5, 10))
>>> foo2 = Foo({'one': 1, 'two': 2})
>>> foo1[3]
8
>>> foo2['one']
1

Or are you saying that only classes specifically derived from list,
tuple, or dict should be considered, and custom containers that are
not derived from any of those but implement the correct protocols
should be excluded?  If so, that sounds less than ideal.

Cheers,
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to