4

I am attempting to convert Java code to Jython and am using the apache Log and LogFactory imports. I am attempting to emulate Foo.class in Jython The chunk of code is as follows: in 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
    }

How can I emulate this same behavior of MyClass.class in Jython/Python?

2
  • You do realize you can import java classes in jython right? Commented May 31, 2012 at 16:16
  • Yes I have the imports, The issue is emulating MyClass.class Commented May 31, 2012 at 17:27

1 Answer 1

3

To illustrate my comment:

from org.apache.commons.logging import LogFactory

class MyClass(object):
    def __init__(self, dom):
        "code"

log = LogFactory.getLog(MyClass)

Or

MyClass.log = LogFactory.getLog(MyClass)
Sign up to request clarification or add additional context in comments.

1 Comment

I suspect OP didn't grasp that in jython MyClass corresponds to java's MyClass.class, i.e. there is no .class attribute of a class

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.