简体   繁体   中英

Jython override method with same name

I saw a similar problem occurred on JRuby back in 2010 when we would try to override in Jruby a method that was overloaded orginally on the java source code. How do we deal with this in Jython? More specifically, how can i specify for one of the methods that are overloaded to be override and ignore the remaining or how can I override all of them?

Thank you

Python does not support method overloading (but it does support default values).

def my_function(paramA, paramB = None):
  pass

Since Jython is merely a Python implementation, I belive the same stands true.

To call a specific Java method from Jython, you may have to make the types match very closely, or even exactly.

Jython does some type coercion , but there are situations in which this does not select the the method you want.

To call public methods on specific base classes you can use BaseClass.method(self, ...) . To call protected methods you must prefix the method name like self.super__method(...) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM