From: Samuele P. <pe...@in...> - 2002-03-23 01:17:07
|
From: Edward Povazan <epo...@te...> > Ok, > I have __init__.py in the proper places. > I have this hierarchy > /impi > /impi/core > /impi/core/Impi.class # java class with static methods, ie "looks like a > module" > /impi/core/editors.py # a bunch of basic gui's used by the app. > > In a jython console, I can do this: > from impi.core import * # works ok but does it get you Impi? it shouldn't. > from impi.core.editors import * # I get the exception here > > editors.py contains: > from impi.core import * > > > But so your from impi.core import * will never > > get you the Java class. Anyway why the error? > In the console > from impi.core import * works fine, and I can call the static methods in > class Impi. Just when import is from another file, I get the problem. > > > The thing you haven't said to us > > is that you are doing the > > from impi.core import * > > from a module inside impi.core, is that true? > Yes, from editors.py A-ah, you get the error because Python import are interpreted first as relative to the package of the current module: that means that inside import.core.editors from impi.core import * tries from impi.core.impi.core import * before from impi.core import * # top-level impi now the first should fallback to the second because Impi.class is not impi something, So it seems we have still a case-sensitivity problem we shouldn't have anymore. That one is a bug :(!. OTOH from py.pkg import * never gets to the possible Java classes inside py.pkg, the single import yes or if you have already imported them otherwise. from java.pkg import * works OTOH. Now for a workaround, it really depends on what do you want to get with from impi.core import *? regards. PS: as a style note it is better to avoid import * in production code. |