question in "A Simple Game" in oop lesson | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

question in "A Simple Game" in oop lesson

https://www.sololearn.com/learning/1073/2474/5147/1 class GameObject: class_name = "" desc = "" objects = {} def __init__(self, name): self.name = name GameObject.objects[self.class_name] = self def get_desc(self): return self.class_name + "\n" + self.desc class Goblin(GameObject): class_name = "goblin" desc = "A foul creature" goblin = Goblin("Gobbly") def examine(noun): if noun in GameObject.objects: return GameObject.objects[noun].get_desc() else: return "There is no {} here.".format(noun) --------------------------------------------------------------- class_name = "" desc = "" what does this line mean AND what does do?

4th Dec 2020, 4:22 PM
Sahar
Sahar - avatar
8 Answers
+ 2
Yes you are right, they are just defining class property of a parent class.
4th Dec 2020, 5:20 PM
Gordon
Gordon - avatar
+ 2
Are you talking about this lesson? https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2474/ Where is such line?
4th Dec 2020, 4:45 PM
Gordon
Gordon - avatar
+ 2
Do you mean class_name = "" and desc = "" which are in class GameObject:?
4th Dec 2020, 4:49 PM
Gordon
Gordon - avatar
+ 1
I didn't get it, python course was changed?
4th Dec 2020, 4:45 PM
Sahar
Sahar - avatar
+ 1
oh, I'm sorry, I think they are just defining parameters for a string.
4th Dec 2020, 4:54 PM
Sahar
Sahar - avatar
0
Alright,that line is just the bottom border of the code box.
4th Dec 2020, 4:46 PM
yingSSS['book'=="本"]
- 1
Maybe you should update the course
4th Dec 2020, 4:35 PM
yingSSS['book'=="本"]