logo       

Re: Re: Simple but fundamental: How to import a jython class?: msg#00026

lang.jython.user

Subject: Re: Re: Simple but fundamental: How to import a jython class?

If you want use the class X write this:

from x import *  (x if yor archive is x.py and X if your archive is X.py)


now the program y.py look's somting like this:

from x import *
a = X()
a.hello()

another form to use your library:

import x (x if yor archive is x.py and X if your archive is X.py)
a=x.X()
a.hello()





Aziz Hammadi <aziz.hammadi@xxxxxxxxx> escribió:
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.

Tanks!

Aziz Hammadi



--
Aziz Hammadi Lamrani
email: aziz.hammadi@xxxxxxxxx
url: http://user.et-cip.rub.de/hammadi/
http://jprog.blogspot.com/
N¬HS^µé??X¬²?'²?Þu¼±<ÂÚ?º.?Öëy©"? ®*m?x%jx.j­?«^Æ×§vÆ©¦X?jب?ȧ¶?m©Ý??â?é?v&?¶×§vØ^?+ÞÁæÜjËZ?Øè?{az?â?ç^½éh¥êà®?©n·??)à?{h¶¬?ì¡Ø§?׫®+h¯(m¶?ÿ±éZ²ëjY?w­þÇ¥rg?y$?õ×Oxá¸?n5ïmjõÛ^¸Ø?­??î±êì?¨¥?x%?ËIÊØh?ë®Éb²Û,¢êÜyú+?éÞ¶m¦Ïÿ?+-²Ê.­Ç?¢¸?ë?+-³ùb²Ø§~?ãÊØh?ë®


Do You Yahoo!? La mejor conexión a Internet y 2GB extra a tu correo por $100 al mes. http://net.yahoo.com.mx
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise