logo       

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

lang.jython.user

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

Aziz Hammadi 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 is now bound to the module x, not the class within the module. The class is an attribute of the module: x.X
x = X()
Should be
anX = x.X()

Don't reuse the name x, you lose the binding to the module and you won't be able to create any more x.X.

This is basic Python stuff, you might want to look at a tutorial such as
http://docs.python.org/tut/node8.html

or one of the beginner tutorials here:
http://wiki.python.org/moin/BeginnersGuide/NonProgrammers

Kent



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise