Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8791

Re: [Python-ideas] Allow isinstance second argument to be a set of types

References (4 earlier) <CAGE7PN+KBhEUg=KOxOBaF2=EEQ=Jt=Erq=si1cmYur8TbKtHuw@mail.gmail.com> <CAGE7PNJV0u_4KuQY8ShYpZCnXwEYUhHYAcxRwi6nXTGHgeYxmg@mail.gmail.com> <1309802125.3688.54.camel@localhost.localdomain> <CAGmFidbVGr-sVAzSgXu0SR5cjZgUGbhZBNqSAuWjJNOkjnL3qg@mail.gmail.com> <4E121A4B.2040008@mrabarnett.plus.com>
Date 2011-07-04 13:09 -0700
Subject Re: [Python-ideas] Allow isinstance second argument to be a set of types
From Chris Rebert <clp2@rebertia.com>
Newsgroups comp.lang.python
Message-ID <mailman.605.1309810195.1164.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Jul 4, 2011 at 12:53 PM, MRAB <python@mrabarnett.plus.com> wrote:
> On 04/07/2011 20:41, Amaury Forgeot d'Arc wrote:
>>> Le lundi 04 juillet 2011 à 10:52 -0700, Gregory P. Smith a écrit :
>>>>
>>>> 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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: [Python-ideas] Allow isinstance second argument to be a set of types Chris Rebert <clp2@rebertia.com> - 2011-07-04 13:09 -0700

csiph-web