Simple but fundamental: How to import a jython class?
Fredrik Lundh
fredrik at pythonware.com
Thu Mar 23 08:36:07 EST 2006
aziz.hammadi at gmail.com wrote:
>I wrote a jython class bus I can not use it in another jython script
> :-(
> Example:
> ---------------------- X.py----------------------
> class X:
> def hello():
> print "Hello"
>
>
> ---------------------- Y.py----------------------
> import X
> x = X()
> x.hello()
>
> I get TypeError: call of non function (module 'X')
> Both files are in the same directory.
after you've done "import X", the name X refers to the namespace of the
module X.py, not the class (or any other object) in that module. to access
the class, use dot notation:
x = X.X()
</F>
More information about the Python-list
mailing list