I have a curiosity question. There was an exercise that asked the user to test for a whether a passed in value was of a certain type, “int” or “float”… for example. I thought I would have to compare it to a string:
if (type(num) == “int”):
But that gets an error.
It turns out it is looking for a literal… no quotes around it. I noticed that if I do this:
the console shows something like <type: int> or <type: float>
So my question is regarding how does Python parse this when running a comparison?
In otherwords, how does <type: int> == int ? is this under the hood magic?