+ 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?

15th May 2018, 10:46 AM
scientist
scientist - avatar
6 ответов
+ 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
15th May 2018, 11:21 AM
Scooby
Scooby - avatar
+ 2
cyk you are confusing Python with other popular programming languages. in Python you do not have to use the new keyword. to instantiate objects.
15th May 2018, 1:21 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 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
15th May 2018, 1:39 PM
cyk
cyk - avatar
+ 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 :)
15th May 2018, 12:14 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 1
So can I say, James (or John) is an instance a Person object? Am I right??
15th May 2018, 1:27 PM
scientist
scientist - avatar
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.
15th May 2018, 1:34 PM
scientist
scientist - avatar