Simple but fundamental: How to import a jython class?

Frank Schenk frank at ypsilon.net
Thu Mar 23 14:02:23 CET 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.

try
from X import X
or
x = X.X()


Frank



More information about the Python-list mailing list