+ 1

Objects in python

What does it mean to “reference an object”? I was trying to create a code where it uses a function from a different class. I was told i have to reference an object before adding the function. What does this mean? Thanks

2nd Oct 2019, 12:08 PM
Luna
3 Answers
+ 4
Functions in classes are called methods, and they're supposed to be only accessible via the class and its instances. Take a simple Python list for example. a_list = [1, 3, 2] a_list.sort() If you print out that list later, it will be sorted. But sort belongs to lists, so you always have to call it *with* a specific list (an object/instance) as you just saw here.
2nd Oct 2019, 12:33 PM
HonFu
HonFu - avatar
+ 4
Luna, may be you can post or link your code here so that we can have a clear picture from what happens.
2nd Oct 2019, 12:47 PM
Lothar
Lothar - avatar
0
my question links to this problem :) https://www.sololearn.com/discuss/2023682/?ref=app
3rd Oct 2019, 10:29 AM
Luna