Jython: is there a clean way to implement a Java interfaces with function references?
Posted
by auramo
on Stack Overflow
See other posts from Stack Overflow
or by auramo
Published on 2010-03-24T07:38:59Z
Indexed on
2010/03/24
7:43 UTC
Read the original article
Hit count: 264
jython
I know that I can implement a Java interface with Jython like this:
class MyListener (Listener):
def foo(self, event):
print(str(event))
Python has first-class functions so that seems like an overkill - especially for interfaces with one method. Is there a way to just pass a lambda or function which implements a single method in an interface instead?
© Stack Overflow or respective owner