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
6 Answers
+ 2
Check this out:
https://code.sololearn.com/c1Pbqx2LpGjo/?ref=app
+ 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
+ 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 đ
+ 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
0
Anton Böhler you dont read my code, dont you?