我正在尝试将Java代码转换为Jython并使用apache Log和LogFactory导入。我试图在Jython中模拟Foo.class代码块如下: 在Java中
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class MyClass {
private static final Log log = LogFactory.getLog(MyClass.class);
public MyClass(Document dom)
{ //code
}
如何在Jython / Python中模拟MyClass.class的相同行为?
答案 0 :(得分:3)
说明我的评论:
from org.apache.commons.logging import LogFactory
class MyClass(object):
def __init__(self, dom):
"code"
log = LogFactory.getLog(MyClass)
或者
MyClass.log = LogFactory.getLog(MyClass)