Python 3 isinstance
Carl Banks
pavlovevidence at gmail.com
Thu Jan 15 16:43:37 EST 2009
On Jan 15, 1:08 pm, Duncan Booth <duncan.bo... at invalid.invalid> wrote:
> Carl Banks <pavlovevide... at gmail.com> wrote:
> > I don't see what the big deal is. Right now isinstance accepts a type
> > or a tuple of types. The code could be changed to allow a type, or
> > any iterable the returns types (wherein every items of the sequence is
> > required to be a type). What's messy about that?
>
> No, it isn't restricted to a type or a tuple of types: right now isinstance
> accepts X where X is a type or a tuple of X. The definition is recursive,
> and the data structure can be deeply nested, but (because tuples are
> immutable) it cannot be infinite.
>
> e.g.>>> isinstance('x', (((((int, (float, str)),),),),))
>
> True
Oh. Not sure what the use case for THAT was, but that would make
things messy.
Carl Banks
More information about the Python-list
mailing list