|
From: Samuele P. <pe...@in...> - 2001-05-30 17:11:18
|
Hi.
It was just a pilot error <wink>.
Your java class is foo.python.Foo2, you can't get at it as foo.Foo2 in any
case.
Let's see and clarify some other points:
>>> dir ('foo')
[]
I think you meant dir(foo), dir('string') returns always [].
Then:
Jython 2.0 on java1.3.0 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> from foo import *
>>> dir() # current namespace binding names
['Foo', '__doc__', '__name__']
>>> # dir(foo) will fail
>>> Foo()
<foo.Foo instance at 5691336>
>>> python.Foo2() # fails
Traceback (innermost last):
File "<console>", line 1, in ?
NameError: python
>>> # but
>>> import foo
>>> dir(foo)
['Foo', '__doc__', '__file__', '__name__', '__path__']
>>> # jython backtracks
>>> foo.python.Foo2()
foo.python.Foo2@5d5681
>>> ^D
Worth to notice: with respect to from import * and dir a python package
behaves the usual way even when it shadows a java package, making it work
differently will mess up jython code without a real gain: in any case, from
import * and dir nice features with java packages are intended for explorative
interactive use, not for production time. On the other hand
jython backtracks properly to the java package.
regards. Samuele Pedroni.
|