Your current code should work.

Regarding the previous emails: assuming you have imported names properly (as Alex mentioned), you still have to deal with instances vs classes (as Cliff points out). In current Jython (2.5), you can simply use the @staticmethod decorator, as documented here. That should do what you originally wanted. However, it's not common usage in Python to group functions as static methods, unlike in Java. Instead functions are typically just defined at the module level, as you did in this last email.

One other thing. You mentioned this in the context of IBM RSA/WebSphere. I'm not familiar with WebSphere, however http://wiki.python.org/jython/WebSphere mentions that it only supports Jython 2.1. This is a very old version, and it also doesn't support staticmethod in any form.

So it looks like you have another problem occurring. Perhaps the WebSphere Jython book will help? Or a WebSphere specific mailing list?

- Jim

On Thu, Oct 7, 2010 at 7:16 AM, rag007 <rageshsharma.s@hcl.com> wrote:

Hi,

Thanks for your kind reply. But still i am getting the same problem. I dont
know why?
I am using like this

#TestModule.py
def testMethod():
       print "Hello World"

#Test.py
import TestModule
TestModule.testMethod()

I am getting the same error like "ImportError: no module named TestModule"

I am using IBM RSA. I created one jython project and add those files which
as mentioned above in the project. I am using Websphere server to run the
jython script. Why it is coming like that?
I tried sample application like print "HelloWorld". Its working properly.
Please reply me.

rag007 wrote:
>
> Hi,
>
> Thanks for your kind reply. But still i am getting the same problem. I
> dont know why?
> I am using like this
>
> #TestModule.py
> def testMethod():
>       print "Hello World"
>
> #Test.py
> import TestModule
> TestModule.testMethod()
>
> I am getting the same error like "ImportError: no module named TestModule"
>
> I am using IBM RSA. I created one jython project and add those files which
> as mentioned above in the project. I am using Websphere server to run the
> jython script. Why it is coming like that?
> I tried sample application like print "HelloWorld". Its working properly.
> Please reply me.
>
>
>
>
>
> rag007 wrote:
>>
>> Hi All,
>>
>> This is rakesh. I am new to Jython. I created two Jython Script
>> TestClass.py and Test.py
>> In TestClass.py, I have one methond testMethod(). How can i call the
>> testMethod in the Test.py.
>>
>> #TestClass.py
>> class TestClass:
>>             def testMethod():
>>                      print "Hello World"
>> #Test.py
>> import TestClass
>> TestClass.testMethod()
>>
>> I called like this way I got "ImportError: no module named TestClass"
>>
>> I know execFile. But in execFile we will give full path right?
>>
>> How to resolve?
>>
>>
>>
>
>

--
View this message in context: http://old.nabble.com/Import-Jython-Script-and-access-methods-from-another-Jython-Script-tp29898645p29903594.html
Sent from the jython-users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users