csev/py4e

Chapter 14#Different results of Multiple instances from the text

joilo opened this issue · 1 comments

joilo commented

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.