is_alive


#1

What is the essence of is_alive in this code below
lass Animal(object):
"""Makes cute animals."""
is_alive = True
def init(self, name, age):
self.name = name
self.age = age

zebra = Animal("Jeffrey", 2)
giraffe = Animal("Bruce", 1)
panda = Animal("Chad", 7)

print zebra.name, zebra.age, zebra.is_alive
print giraffe.name, giraffe.age, giraffe.is_alive
print panda.name, panda.age, panda.is_alive


#2

It makes all animals alive by default. So you don't have to run an extra value through __init__.


#3

Couldnt you do the same thing by defining it within the init?
self.is_alive = True?


#4

Yes, that's how I prefer to do it! :slightly_smiling: