Class - basic concept


Just want to know when we define a method of the class, why we cannot use the argument directly.

For example:

class Employee(object):
"""Models real-life employees!"""
def init(self, employee_name):
self.employee_name = employee_name

def calculate_wage(self, hours):
    self.hours = hours
    return hours * 20.00

In this case, why we need to define self.hours = hours. What if we do not have this statement?

Thank you very much for the reply in advance.


Your class contains code that manages the objects that can be created from the class.

If those objects are supposed to have some certain attributes, then you'll need code that adds those attributes to the objects.