Thanks for the reply David,

I only want to use Jython for my project so i don't really have python.
Im using a combination of jython and java only.
The imports are scattered all over but I don't want to actually manually find them and list them out and detect them in that way,

What I want to do is to automate it - perhaps by writing an import hook which can detect the difference between a java and a jython only module.

What I don't know is how to differentiate between the two. When the modules are imported onto the sys.modules is it possible for me to differentiate between them
or can i find something at the point of import that will help me in differentiating between the two - like a variable or flag or something similar.

Also note that this should happen when the program is running and not a step before running the program.
The reason for doing this is that i am using pychecker in the import mode (import pychecker.checker) - this checks any modules imported after itself. If I can trap the __import__ hook and generate a stub before calling the default __import__ function then im home free!

On 24/08/07, David Handy <> wrote:
Are all of your import statements at the beginning of your modules, before any code?
Is all of the code in your modules wrapped in functions or classes (instead of executed on import)?
Are there one or two modules such that, if you import them they import all of the others? Or could you make a module just for that purpose?
Then just import that module from a Python (not Jython) session, get an import error, write a stub, reload(module), and repeat till the import errors go away.
If you have hundreds of imported java classes, then you could even automate that process:
while True:
        import module
    except ImportError, e:
        # parse java class name out of e.args[0]
        # call function to generate stub for java class
        break # import now successful
Or something like that...
David H

From: [] On Behalf Of Ruchir Talwar
Sent: Friday, August 24, 2007 9:47 AM
Subject: [Jython-users] differentiate between importing java and pythonmodules

I need to differentiate between importing a python module and a java class.
I am trying to get my jython classes to work with pychecker but since i am also importing java classes i had to generate stubs for the java classes.
However I am not using all java classes from the jar files in my classpath so creating the extra stubs for the unused classes is expensive and unnecessary.
What I would like to do is to create stubs for the java classes only when i encounter an import statement for a java class.

Any help on this matter would be appreciated.