Testing the data type of a value

Piet van Oostrum piet-l at vanoostrum.org
Sun May 12 10:07:07 EDT 2019


Luuk <luuk at invalid.lan> writes:

>
> After thinking about this, (i am prettry new to python), i was doing this:
>
>>>> print(type(5),type(int),type(5)==type(int),type(5)==int)
> <class 'int'> <class 'type'> False True
>
> Can someone explain why   type(5)==int   evaluates to   True ?
>
>>> print(int)
<class 'int'>

The value of int is the class int, which is the class of 5, so type(5) is also that same class int.
-- 
Piet van Oostrum <piet-l at vanoostrum.org>
WWW: http://piet.vanoostrum.org/
PGP key: [8DAE142BE17999C4]


More information about the Python-list mailing list