+ 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?
8 Antworten
+ 2
Yes you are right, they are just defining class property of a parent class.
+ 2
Are you talking about this lesson?
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2474/
Where is such line?
+ 2
Do you mean
class_name = ""
and
desc = ""
which are in class GameObject:?
+ 1
I didn't get it, python course was changed?
+ 1
oh, I'm sorry, I think they are just defining parameters for a string.
0
Alright,that line is just the bottom border of the code box.
- 1
Maybe you should update the course