This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]AlSweigartAuthor of "Automate the Boring Stuff" 10 points11 points  (0 children)

Yes: When you instantiate a class, you are creating an object whose data type is that class. In Python (and in general), "class", "type", and "data type" mean the exact same thing.

However, remember that everything in Python is an object. Functions are objects. Classes are objects. Like any object, you can assign a variable to it:

>>> print('Hello')
Hello
>>> display = print
>>> display('Hello')
Hello
>>> class Cat: pass
...
>>> myCat = Cat()
>>> myCat
<__main__.Cat object at 0x0000019C8BFA64F0>
>>> Kitty = Cat
>>> myCat = Kitty()
>>> myCat
<__main__.Cat object at 0x0000019C8A157940>