Im having trouble understanding the static method decorator, im a beginner and in the book im reading the static method decorator doesnt seem to do anything, there is some code in the book and it demonstrates the static methods which makes the decorator seem essential so i took it out to test and the code runs the same.
Are they just to make the static method more human readable or is this just a bad example or am i missing something else??
Code:
# Classy Critter
# Demonstrates class attributes and static methods
class Critter(object):
"""A virtual pet"""
total = 0
@staticmethod
def status():
print("\nThe total number of critters is", Critter.total)
def __init__(self, name):
print("A critter has been born!")
self.name = name
Critter.total += 1
forgot to mention, all the main text does is create an object Critter and invoke its status() method
Bookmarks