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
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 =...).
+ 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
+ 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.
+ 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)
+ 1
If you and I have the same radio from the brand X, then both our radios are instances of the class X.
+ 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?
0
D_Stark So an instance of class is quick-use class?
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?