Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; 'mrab': 0.05; 'subject:Python': 0.06; '>>>>': 0.09; 'exception.': 0.09; 'subclass': 0.09; 'type)': 0.09; 'subject:] ': 0.14; 'wrote:': 0.15; '(via': 0.16; 'arbitrarily': 0.16; 'element,': 0.16; 'gotta': 0.16; 'lookup': 0.16; 'metaclass': 0.16; 'subject:set': 0.16; '\xc3\xa9crit': 0.16; 'mon,': 0.16; 'pm,': 0.16; '>>>': 0.16; 'cheers,': 0.19; 'header:In-Reply-To:1': 0.22; 'gregory': 0.23; 'received:209.85.213.46': 0.23; 'received:mail- yw0-f46.google.com': 0.23; 'suspect': 0.25; 'raise': 0.28; 'objects': 0.28; 'message-id:@mail.gmail.com': 0.28; 'cases.': 0.30; 'iterating': 0.30; 'types.': 0.30; 'chris': 0.32; 'actually': 0.33; 'to:addr:python-list': 0.34; 'implies': 0.35; 'probably': 0.35; 'anything': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'else': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.40; 'back': 0.63; 'making': 0.66; 'exact': 0.69; '10:52': 0.84; '12:53': 0.84; 'beware': 0.84; 'sender:addr:chris': 0.84; 'subject:types': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=gcJED3u9+Tf7PI1L7gPnV8LGGSR5WCIajhf+09FergA=; b=BkRVkgNRvTqjtEmllEu20zMVFv7Xxr7B2gsBckAuFXQREscgWq4XTM6PwuauYVesPi dRzd6MoU64EaOWXPn3ovGzi9rmYfgFo04cSMJ+g7YLpbI2feZkottKc9imLAQJAmcl5s Ih5rQsoDukqJ/zOMp/p/He0A8sRTIRwP26MnE= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: <4E121A4B.2040008@mrabarnett.plus.com> References: <4E11656B.4050908@canterbury.ac.nz> <20110704172843.50c5b445@pitrou.net> <1309802125.3688.54.camel@localhost.localdomain> <4E121A4B.2040008@mrabarnett.plus.com> Date: Mon, 4 Jul 2011 13:09:52 -0700 X-Google-Sender-Auth: PUAw2KYYSSHTPzcwz8nJCxHYQhk Subject: Re: [Python-ideas] Allow isinstance second argument to be a set of types From: Chris Rebert To: python-list@python.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1309810195 news.xs4all.nl 21862 [2001:888:2000:d::a6]:49837 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8791 On Mon, Jul 4, 2011 at 12:53 PM, MRAB wrote: > On 04/07/2011 20:41, Amaury Forgeot d'Arc wrote: >>> Le lundi 04 juillet 2011 =C3=A0 10:52 -0700, Gregory P. Smith a =C3=A9c= rit : >>>> >>>> note that a fast lookup implies exact type and not subclass making my >>>> point silly... at which point you're back to iterating so I suspect >>>> supporting arbitrary iterables is actually how this will be >>>> implemented regardless. >> >> Arbitrary iterables, arbitrarily nested... >> beware of objects which are also their first element, like str('a')... >> > Probably not arbitrarily nested, just a type (type(t) is type) or an > iterable yielding types. Anything else would raise an exception. What about a type that is itself iterable (via metaclass magic)? Gotta consider the wacky edge cases. Cheers, Chris