[Tutor] isinstance versus 'is'?
Joel Goldstick
joel.goldstick at gmail.com
Tue Jul 5 18:49:38 EDT 2016
On Tue, Jul 5, 2016 at 3:05 PM, Alex Hall <ahall at autodist.com> wrote:
> Hi all,
> Thanks for all the help regarding decorators. It makes more sense now.
>
> I was double checking that I remembered the isinstance order of arguments
> correctly by using the command line interpreter, and found something very
> odd.
>
>>>> a = 5
>>>> isinstance(a, int)
> True
>>>> a is int
> False
>
> What happened there? Don't these do the same thing? I thought I could use
> them interchangeably?
>
> --
> Alex Hall
> Automatic Distributors, IT department
> ahall at autodist.com
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
is denotes identity. 5 is not the type int. It is an int, but it is
not the same -- if it was 5('16') would be 16.
--
Joel Goldstick
http://joelgoldstick.com/blog
http://cc-baseballstats.info/stats/birthdays
More information about the Tutor
mailing list