|
From: Chris W. <cw...@am...> - 2001-05-30 01:26:10
|
I have python.path set to ~/lib/python and my CLASSPATH set to . and I
cd to src before I start up jython.
Here is what I got in my path.
src/foo/python/Foo2.class
src/foo/python/Foo2.java
lib/python/foo/__init__.py
lib/python/foo/__init__$py.class
(See attach tar for the source code.)
__init__.py contains one jython class called Foo
Here is what I did.
~/src% export CLASSPATH=.
~/src% jython
Jython 2.0 on java1.3.1 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> from foo import *
>>> dir ('foo')
[]
>>> Foo()
<foo.Foo instance at 7127716>
>>> Foo2()
Traceback (innermost last):
File "<console>", line 1, in ?
NameError: Foo2
>>> import foo
>>> foo.Foo2()
Traceback (innermost last):
File "<console>", line 1, in ?
AttributeError: module 'foo' has no attribute 'Foo2'
>>>
As you can see, Foo was created correctly, but when I try to create Foo2,
it said module 'foo' has no attribute 'Foo2'. It looks like that it's not
backtracking in this case. Is this normal?
Thanks for any help.
Chris
On Sun, May 27, 2001 at 09:46:29PM +0200, Samuele Pedroni wrote:
> Hi.
> >
> > Hi,
> >
> > I have a jython package name starting with the same package as my
> > java package. e.g.,
> >
> > foo/bar/test.py in Jython
> >
> > and
> >
> > foo/jython/rocks/RockTheWorld.class in Java
> >
> > Let's say I want to use RockTheWorld which is a Java class.
> > Normally, we use
> >
> > from foo.jython.rocks import *
> >
> > However, since the jython package has precendence over the Java
> > classpath, Jython says it couldn't find "jython" package. The
> > reason is because both package path starts with foo.
> >
> > Here is my question: Why didn't Jython backtrack to try the rest
> > of the path to find foo.jython.rocks package? Is this a bug?
> >
> As far as I know jython backtracks. This is - however - not true with
> jythonc-ompiled code. Is that your case? otherwise you should come
> with a detailed not working case, I have just tried with an example
> case and everything works fine.
>
> regards.
>
|