On 23/05/2021 06:37, hw wrote:

Hi,

I'm starting to learn python and have made a little example program following a tutorial[1] I'm attaching.

Running it, I'm getting:


Traceback (most recent call last):
   File "[...]/hworld.py", line 18, in <module>
     print(isinstance(int, float))
TypeError: isinstance() arg 2 must be a type or tuple of types


I would understand to get an error message in line 5 but not in 18.  Is this a bug or a feature?

It is a bug in your code (which you don't provide). Did you assign some value to float, e. g.:

>>> float = 42.0
>>> isinstance(int, float)
Traceback (most recent call last):
  File "<pyshell#313>", line 1, in <module>
    isinstance(int, float)
TypeError: isinstance() arg 2 must be a type or tuple of types

If you do not shadow the built-in you should get

>>> isinstance(int, float)
False

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to