Ex42, confused between Object & Class in Python

Hi all,

I am reading ex42. Before this ex 42. I was thinking of defining a class as below

class Animal(object):

Animal is the class name. And when you say cat=Animal(), you define an object cat using the class Animal.

But ex42 told me that

You use the phrase is-a when you talk about objects and classes being related to each other by a class relationship.


## Animal is-a object (yes, sort of confusing) look at the extra credit
class Animal(object):

Here, animal seems a less abstract concept and object is the more abstract one. If I understand correctly, class is an abstraction of a type of objects. However, this is not consistent with the book.

Maybe I get things wrong. Can someone help to clarify? Thank you!

No that’s right. “object” is very generic, “Animal” is slightly generic, “Salmon” is less generic, and this is very specific:

jonas = Salmon()

That would make a specific instance of salmon.

I think I get a bit now.

you can define a class from more generic classes as well, right?

Like Dog and Cat are derived from the class Animal.

Yes, that’s actually the only thing you can do. You can’t really “define” a generic class from a specific one.