+ 1
What does "object instance" mean?
I was reading about mutable and immutable data types when I came across the following line: "......every variable holds an object instance. " What does "object instance" mean, also explain what does this line mean?
6 Answers
+ 7
The creation of an instance is called instantiation. In class-based programming, objects are created from classes by subroutines called constructors, and destroyed by destructors. An object is an instance of a class, and may be called a class instance or class object; instantiation is then also known as construction.
https://docs.python.org/2/tutorial/classes.html
https://stackoverflow.com/questions/2885385/what-is-the-difference-between-an-instance-and-an-object
+ 2
Yes you can say that James and John are instances of the Person class and like bahhax404 not all languages use the new keyword. Java does for instance but Python doesn't
+ 1
in simple terms
suppose you have a variable x, when you write
x=10;
you asign a value to it (10) it's like instantiating it.
for objects. when you have a class. and you create an object of that class.
when you give it a value then it's instantiated.
example :
if you have a class called Student.
when you write:
Student student1
then student1 is just an object but not instantiated yet
when you do
student1 = Student()
then you just instantiated student1
hope it makes sense :)
+ 1
So can I say, James (or John) is an instance a Person object?
Am I right??
0
That thing,
student1 = new Student(),
I learnt from the sololearn Js tutorial, but didn't knew what that was called in 'book' language.
I recently started learning Python.