What is Instance btw?! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is Instance btw?!

English is not the language i use most. So can anyone tell me what is Instance stand for. By simple words if you can. thanks you

10th Aug 2019, 11:11 AM
Nguyễn Tín
8 Answers
+ 1
_a is a class variable, because you define it for the whole class. So every instance will have access to that value. Instance variable have to be created over the methods (the pattern being self.name =...).
11th Aug 2019, 7:20 AM
HonFu
HonFu - avatar
+ 3
You create an instance of class which is an object of that class by using the new keyword and calling its constructor. You have instance methods and variables which are those you declare inside the class. You have to create an instance of class to use its instance variables and methods
10th Aug 2019, 11:14 AM
D_Stark
D_Stark - avatar
+ 2
Yes. But maybe a less abstract example. class Point: def __init__(self, x, y): self.x = x self.y = y point1 = Point(5, 7) point2 = Point(8, 12) point3 = Point(-5, 5) The class definition specifies what a Point is (in this case just a 'container' for two values. Now this is only the blueprint. point1, point2 and point3 are instances of Point, each with their own two values.
10th Aug 2019, 11:38 PM
HonFu
HonFu - avatar
+ 1
Not sure what quick-use class is, but it's just a complete object of that class like you have the blueprints of car (class) and you create the object (the car)
10th Aug 2019, 11:38 AM
D_Stark
D_Stark - avatar
+ 1
If you and I have the same radio from the brand X, then both our radios are instances of the class X.
10th Aug 2019, 11:43 AM
HonFu
HonFu - avatar
+ 1
HonFu [#GoGetThatBugChamp!] thanks you. and can you give me a simple of instance variables? Is that like: class Point: ___a = 8 def Add() In this case __a is an instance variable, Add is an instance method?
10th Aug 2019, 11:43 PM
Nguyễn Tín
0
D_Stark So an instance of class is quick-use class?
10th Aug 2019, 11:22 AM
Nguyễn Tín
0
HonFu [#GoGetThatBugChamp!] so let me get this a last try. if i have a class Cat so an object of Cat is "a cat". So an instance of the class can be "a cat's leg" "a cat's eye". And even "a cat" is an instance of the class. And a method of the class is an instance too? So in same way we can say an instance of the class is the object too?
10th Aug 2019, 11:33 PM
Nguyễn Tín