def my_func():
another_func(lambda: ...)
you can write def my_func():
def inner(): ...
another_func(inner)
Sure, it's creating a function, naming it, then immediately throwing it away, but gets the job done with minimal extra boilerplate. @foo.on_click
def foo_clicked(): ...
Of course, for this, foo.on_click needs to be a callable function rather than a property.