[PYTHON] What is an instance variable?

What is an instance in the first place?

An instance is like an entity created by a class. A class is a blueprint, and what is created by a class (blueprint) is called an instance.

As a concrete example, let's say you made a Benz based on a car blueprint. Here, the blueprint of the car is the class and Benz is the instance.

What is an instance variable?

Instance variables are values that are valid only within a particular instance. In addition, there is a class variable as a term that tends to have a mixed meaning with an instance variable. Consider the difference between the two words in the car example above.

Suppose you have "4 tires" and "car shape" on your car's blueprints. The design of "4 tires" is a design that applies to all cars, and it is a common value within the class (in the blueprint). In other words, every car must have four tires.

On the other hand, the "shape of the car" differs depending on the model. Therefore, the shape of the car used in each instance is different, such as this shape when making Benz, this shape when making Prius, and so on. Values that are valid only within each instance are called instance variables.

Finally

This article is a transcript of my head to confirm my understanding. It may be wrong, so please point it out.

Recommended Posts

What is an instance variable?
What is an iterator?
Python> What is an extended slice?
What is namespace
What is copy.copy ()
What is Django? .. ..
What is dotenv?
What is POSIX?
What is Linux
What is SALOME?
[Statistics for programmers] What is an event?
What is Linux?
What is python
What is hyperopt?
Python is instance
What is Linux
What is pyvenv
What is __call__
What is Linux
What is Python
[What is an algorithm? Introduction to Search Algorithm] ~ Python ~
What is a distribution?
What is Piotroski's F-Score?
What is Raspberry Pi?
[Python] What is Pipeline ...
What is Calmar Ratio?
What is hyperparameter tuning?
What is a hacker?
What is JSON? .. [Note]
What is Linux for?
What is a pointer?
Metaclass and is instance
What is ensemble learning?
What is TCP / IP?
What is Python's __init__.py?
What is UNIT-V Linux?
[Python] What is virtualenv
What is machine learning?
[Ruby / Python / Java / Swift / JS] What is an algorithm?
[Statistics] Understand what an ROC curve is by animation.
python (2) requires self because the method is an instance method
What is Minisum or Minimax?
What is Linux? [Command list]
What is Logistic Regression Analysis?
What is the Linux kernel?
Python is an adult language
Trouble when pickling an instance
What is a decision tree?
What is a Context Switch?
What is Google Cloud Dataflow?
[DL] What is weight decay?
[Python] Python and security-① What is Python?
What is a super user?
Competitive programming is what (bonus)
[Python] * args ** What is kwrgs?
What is a system call
[Definition] What is a framework?
What is the interface for ...
What is Project Euler 3 Acceleration?
What is a callback function?
What is the Callback function?