Thanks Jeff. I see your and finn's replies ( at
) and wonder why doesn't Jython reflect on Java String
and find out all the classes and interfaces it inherits, and
test if c is an instance of any of them, instead of hard-
wiring it like:
> if (c == String.class || c == Object.class || c == Serializable.class)

Jeff Emanuel <> wrote:

Please look in the mailing list archives for a recent
discussion on converting jython strings to CharSequence.
The same issues apply.

-----Original Message-----
From: maohai huang []
Sent: Tuesday, April 22, 2003 4:47 PM
Subject: [Jython-users] Jython string coercion to java String

hi, I have this java class

public class Foo {
public void com(java.lang.Comparable c) {

in jython I want to pass it a jython string:

Jython 2.1 on java1.4.1_01 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> import Foo
>>> f=Foo()
Traceback (innermost last):
File "", line 1, in ?
TypeError: com(): 1st arg can't be coerced to java.lang.Comparable

I would expect jython to know that Java String class
implements the java.lang.Comparable interface, and
does some coercion so that it would work, just
as if I typed this:
>>>from java.lang import String

Am I missing something? sorry if this is an old question.

Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.