# example2.py # Steve Marschner (srm2) # Lecture demo: A class that defines a few things that go in the class, # illustrating class variables and methods class Example2(object): """A class that defines some things. Attributes: b: an attribute [could be anything]""" # This is a class variable. a = 29 # This is a method that writes to an instance variable. def set_b(self, x): """Assign x to instance variable b""" print type(self) self.b = x # This is a method that reads # from a class variable and an # instance variable. def f(self): """Returns: multiple of class variable a and instance variable b""" return self.a * self.b