An object is an instance (or not)?
Marko Rauhamaa
marko at pacujo.net
Wed Jan 28 00:25:20 EST 2015
Mario Figueiredo <marfig at gmail.com>:
> That is valuable input. You don't care how a type or an instance of a
> type differ. Should be intersting to ask you to make a Cat object. I
> wonder if you are not going to ask if they mean a class or an instance
> of that class.
>
> Anyways, more to the point, this is simply a debate on language and how
> to express Python concepts. If that bothers you, I'll take note.
Python itself has answers to your questions:
>>> isinstance(3, int)
True
>>> isinstance("3", int)
False
>>> isinstance(int, type)
True
>>> isinstance(type, int)
False
>>> isinstance(type, type)
True
>>> isinstance(3, type)
False
>>> isinstance(int, 3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: isinstance() arg 2 must be a type or tuple of types
>>> isinstance(3, object)
True
>>> isinstance("3", object)
True
>>> isinstance(int, object)
True
>>> isinstance(type, object)
True
>>> isinstance(object, object)
True
Marko
More information about the Python-list
mailing list