0

Getting Instance Name of Class

How to get instance's name of my class? Can I? This is the code I wrote to help you answer my unclear question https://code.sololearn.com/ct213F0q2xrY/?ref=app

27th Aug 2019, 11:33 AM
Prasetya
Prasetya - avatar
6 Answers
29th Aug 2019, 5:50 PM
Prasetya
Prasetya - avatar
+ 2
https://code.sololearn.com/cou0JBb5Oh9H/?ref=app that's not what you want exactly, but that's a way you could do it. (I also simplified it and corrected some spelling errors) but it's impossible to get the name of a variable, example: guy = new Hero("sven") girl = guy wanting to get the variable name that points to the Object 'sven' is now complicated, since there are multiple ones, how would you know which one to chose? on the other hand python doesn't care about the name of an variable it only knows there is a variable that holds something
27th Aug 2019, 2:14 PM
Anton Böhler
Anton Böhler - avatar
+ 2
not quite ... if you make a second hero with no quotes and call it's quote it will take the name of the first Hero 😅
29th Aug 2019, 6:47 PM
Anton Böhler
Anton Böhler - avatar
+ 1
Anton Böhler OK, got it You should say "in short, you can't. But ..." so there won't be... forget it! About spelling error, I just finished python tutorial about data hiding and property, so my code focuses there. And thanks, really, thank you, glad to be helped
27th Aug 2019, 6:52 PM
Prasetya
Prasetya - avatar
0
Anton Böhler you dont read my code, dont you?
27th Aug 2019, 12:45 PM
Prasetya
Prasetya - avatar