how to call a function as an argument inside of the function (python)
This is very hard to explain. I might as well just show what I'm trying to do. class Player: def __init__(self, x, y, w, h): self.x = x self.y = y self.w = w self.h = h def keyMove(action): action() As you can see, I will pass a function as a parameter and call it inside the function. Let's just pretend the key functions I will use exist hypothetically. I planning to use it like this: for event in pygame.event.get(): if event.type == UP_ARROW: p.keyMove(upFunction()) elif event.type == DOWN_ARROW: p.keyMove(downFunction()) To clarify, when the player clicks the up arrow, a function gets called, same for down arrow How can I call the functions parameters inside the original function? Sorry, this was very hard to explain.