Python – Party Animal

Python OOP with constructor, revisiting this for an idea.

# Python constructor and objects

class PartyAnimal:
    x, name = 0, ''
    def __init__(self, name):
        self.name = name
        print(self.name,'entity exists')
    def party(self):
        self.x += 1
        print(self.name,'party count',self.x)

q = PartyAnimal('def0day')
m = PartyAnimal('arpsx')

q.party() #give us life
m.party() #but give it meaning
q.party()

Leave a Comment