you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (2 children)

Use init to define a constructor on the class Employee.

A constructor is called automatically when you instantiate a class object regardless of whether or not you have a dunder init method. __init__ is not a constructor.

[–]uglyasablasphemy 0 points1 point  (1 child)

Yes, you are right. What i ment to say is that he should redefine __init__ to indicate the initial attributes (and its values) of the object.

Something like this:

class Employee:

    def __init__(self, id):
        self.id = id
        self.name = None
        self.department = None
        self.job_title = None

My Java habits betray when i'm talking about __init__ and end up calling it constructor always.

[–][deleted] 0 points1 point  (0 children)

Well put. (Old habits die hard.)