Chyanit Singh
Chyanit Singh

Reputation: 113

An object is a named collection of attributes?

Some people refer to objects as "Every python object is a value having a certain type stored at a particular memory location".Some authors define the object as a thing that has a type, value, and identity. I was going through a source and found out a new definition. An object is a named collection of attributes- What does this mean?. If we go through the definitions all of them differ. Are these definitions context specific wherein different definitions are used in different contexts?

Upvotes: 0

Views: 164

Answers (1)

It seems your question is what an object is and because of all the different explanations online it confuses you.

Well, to put is simply. An object is like a blue print. Say you want to write a program that randomly picks a dog and shows the name of the dog. Well the easiest way to solve this, is by creating a dog object.

Every dog should have a name, an owner and perhaps a color. These things would be your attributes. They tell something about the dog. So when you create an instance of a dog, you give it a name, owner name and color. Also when you create an instance you allocate place in memory for that dog object, so you can use it later in your code.

Hope that makes sense. (y)

Upvotes: 1

Related Questions