Is it possible in the Python language to pass a function as an argument? Like, for example, if I wanted to have the following:
a = Item("Elixir", "It restores your health", hp += 5)
And, if so, what would that look like?
Python Argument Passing
What you want to do can be done with Lambda functions. Link: http://www.secnetix.de/~olli/Python/lam ... tions.hawk
Example:
Example:
Code: Select all
a = Item("Elixir", "It restores your health", lambda: hp+=5)