Closed joilo closed 10 months ago
There was definitely some confusion between the book, slides and lectures in Chapter 8. I redid the book, PowerPoint and lectures - so think this has been addressed. Please take a look at
https://www.py4e.com/lessons/Objects
Let me know if this has not been fixed by opening a new issue.
Hi, I am Jess who is a newbie of Python.
In the Multiple instances part of Chapter 14: Python Objects, I run the code given in the online text book but find that the result on my computer is different from that given in the book.
I'm wondering whether it is an error or there're other reasons for that? Here's the code: class PartyAnimal: x = 0 name = '' def init(self, nam): self.name = nam print(self.name,'constructed')
def party(self) : self.x = self.x + 1 print(self.name,'party count',self.x)
s = PartyAnimal('Sally') j = PartyAnimal('Jim')
s.party() j.party() s.party()
Code: http://www.py4e.com/code3/party5.py
Here's my result: Sally constructed Jim constructed Sally party count 1 Jim party count 1 Sally party count 2
And Here's the result on the book: Sally constructed Sally party count 1 Jim constructed Jim party count 1 Sally party count 2
https://www.py4e.com/html3/14-objects
I'm sorry for paying your attention, if someone already reported this issue.