From: Matt W. <mat...@ca...> - 2005-10-28 13:46:20
|
Dear List, I'm still having some odd problems with type checking. 1: What is the way of defining "String" as a class ? >>>a = "hi" >>>isinstance(a,type(a)) >>>1 (as you would expect) - but how do you explicitly define the String type/class? (an see why I don't just write 'str') 2: I get a very odd message when trying to call type(a) from within a java program. Some background - I'm writing an extension to an existing Java program, which has a 'scripting' tab that allows one to call jython. I've modified this so that it loads my default script, which then runs. When I run the script from within Eclipse, it works fine, but when I try and run the main java program (also from within Eclipse), then it barfs on: isinstance(a,str) TypeError: isinstance(): 2nd arg is not a class However, in Eclipse, I get: type("a") results in: TypeError: call of non-function ('string' object) What I don't understand is why it has this behaviour when run via the java program, but not when run via Eclipse. I've made sure that both are using the same jython.jar. Any ideas? (Jython 2.2a1 on FC2; jre1.5.0_01) Thanks, Matt -- Dr. M. Williams MRCP(UK) Clinical Research Fellow Cancer Research UK +44 (0)207 269 2953 +44 (0)7834 899570 http://acl.icnet.uk/~mw http://adhominem.blogspot.com |