Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'considered,': 0.09; 'derived': 0.09; 'dict': 0.09; 'underlying': 0.09; 'am,': 0.12; 'def': 0.13; '2})': 0.16; 'containers': 0.16; 'ideal.': 0.16; 'mapping,': 0.16; 'sequence.': 0.16; 'subject:syntax': 0.16; 'tuple,': 0.16; 'cc:addr:python-list': 0.16; 'mon,': 0.16; 'received:74.125.82.44': 0.16; 'received:mail-ww0-f44.google.com': 0.16; 'meant': 0.17; 'wrote:': 0.18; '>>>': 0.18; 'cc:no real name:2**0': 0.20; 'cheers,': 0.20; 'dec': 0.22; 'header:In-Reply- To:1': 0.22; 'cc:2**0': 0.24; 'saying': 0.26; 'classes': 0.26; 'import': 0.27; 'specifically': 0.27; 'message- id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.29; 'class': 0.29; 'correct': 0.29; 'collections': 0.30; 'false.': 0.30; 'models.': 0.30; 'protocols': 0.30; 'implement': 0.32; 'that,': 0.33; 'received:74.125.82': 0.35; 'but': 0.37; 'list,': 0.37; 'received:74.125': 0.37; 'received:google.com': 0.37; 'skip:_ 10': 0.37; 'should': 0.39; 'type': 0.61; '2011': 0.61; 'custom': 0.61; 'illegal': 0.63; 'care': 0.71; 'concept': 0.74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=0/jBoNu0pMdEJckdFMaGid6nu0qFTB37BSkJoHxfuLY=; b=d92xLII7IvYzEnSm/65zfILeQFBmZ2AItdNQV/IWCha648NCzWDsRxB2dQabvrJmHz bt31YK6lx4vCt3OfCshgXbnGgtlbo944luTIx6+TqrU/T/nDDPyZcVGPOCRIybhnWnJ/ hE4r/23Ww3MkuK4NsR4bORGEAkdDFudMw20R0= MIME-Version: 1.0 In-Reply-To: <1a159184-9262-4b66-88e8-a5b68964d8d7@q16g2000yqn.googlegroups.com> References: <4ee554a3$0$11091$c3e8da3@news.astraweb.com> <5de94e20-314e-4185-ba8f-75e54f87968e@d10g2000vbk.googlegroups.com> <1a159184-9262-4b66-88e8-a5b68964d8d7@q16g2000yqn.googlegroups.com> From: Ian Kelly Date: Mon, 12 Dec 2011 11:35:28 -0700 Subject: Re: Verbose and flexible args and kwargs syntax To: Eelco Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1323714961 news.xs4all.nl 6904 [2001:888:2000:d::a6]:36481 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17074 On Mon, Dec 12, 2011 at 11:17 AM, Eelco 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