Skip to content Skip to sidebar Skip to footer

Python __init__ Issue: Unbound Method __init__() Must Be Called With Bank Instance As First Argument (got Int Instance Instead)

class Teller(object): def __init__(self): self.occupied = False self.timeLeft = 0 self.totTime def occupy(self, timeOcc): self.occupied = T

Solution 1:

2 points to make here:

  1. You shouldn't be calling __init__ directly, it's a magic method which is invoked when you construct an object like this:

    virtBank = Bank(3, 7)
    
  2. The instance is implicitly passed to the constructor, but it must be explicitly received, like this:

    def__init__(self, numTellers, hoursOpen):
        # ...

Post a Comment for "Python __init__ Issue: Unbound Method __init__() Must Be Called With Bank Instance As First Argument (got Int Instance Instead)"