methods inheritance in python
Question: 
    class Field(object):
    
        def __init__(self):
            self.drunks = {}
    
        def addDrunk(self, drunk, loc):
            if drunk in self.drunks:
                raise ValueError('Duplicate drunk')
            else:
                self.drunks[drunk] = loc
    
        def moveDrunk(self, drunk):
            if not drunk in self.drunks:
                raise ValueError('Drunk not in field')
            xDist, yDist = drunk.takeStep()
            currentLocation = self.drunks[drunk]
            #use move method of Location to get new location
            self.drunks[drunk] = currentLocation.move(xDist, yDist)
    
        def getLoc(self, drunk):
            if not drunk in self.drunks:
                raise ValueError('Drunk not in field')
            return self.drunks[drunk]
    
    
        import random
    
    
    def walk(f, d, numSteps):
        start = f.getLoc(d)
        for s in range(numSteps):
            f.moveDrunk(d)
        return(start.distFrom(f.getLoc(d)))
    

i'm learning python.I saw this code and i couldn't understand why the walk
function can use the moveDrunk() method? shouldn't raise an error because
moveDrunk() is from Field class?


Answer: You pass an instance of the `Field` class (`f`) as an argument:

    
    
    def walk(f, d, numSteps):
             ^
    

