Subject: RE: Jython string coercion to java String - msg#00112
List: lang.jython.user
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 [
mailto:lists_mh@xxxxxxxxx]
Sent: Tuesday, April 22, 2003 4:47 PM
To: jython-users@xxxxxxxxxxxxxxxxxxxxx
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
Jython 2.1 on java1.4.1_01 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>
>> import Foo
>
>> f=Foo()
>
>> f.com('as')
Traceback (innermost last):
File "<console>", 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
...
>
>>f.com(String('as'))
Am I missing something? sorry if this is an old question.
thanks
ma0hai
_____
Do you Yahoo!?
The New <
http://us.rd.yahoo.com/search/mailsig/*http://search.yahoo.com>
Yahoo! Search - Faster. Easier. Bingo.
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
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:
jythonJython 2.1 on java1.4.1_01 (JIT: null)Type "copyright", "credits" or "license" for more information.>>> import Foo>>> f=Foo()>>> f.com('as')Traceback (innermost last): File "<console>", 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
...
>>>f.com(String('as'))
Am I missing something? sorry if this is an old question.
thanks
ma0haiDo you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
Next Message by Date:
click to view message preview
Iterating over a SortedMap?
Hi I have a sorted map that I'd like to iterate over like so:
# categories is a java.util.SortedMap ( really a TreeMap )
self.categories = ni.getCategories()
for (category, values) in self.categories:
print "category", category, "values", values
error:
TypeError: loop over non-sequence
What's the most elegant way of doing this?
Thanks!
-Jim
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Previous Message by Thread:
click to view message preview
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:
jythonJython 2.1 on java1.4.1_01 (JIT: null)Type "copyright", "credits" or "license" for more information.>>> import Foo>>> f=Foo()>>> f.com('as')Traceback (innermost last): File "<console>", 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
...
>>>f.com(String('as'))
Am I missing something? sorry if this is an old question.
thanks
ma0haiDo you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
Next Message by Thread:
click to view message preview
Iterating over a SortedMap?
Hi I have a sorted map that I'd like to iterate over like so:
# categories is a java.util.SortedMap ( really a TreeMap )
self.categories = ni.getCategories()
for (category, values) in self.categories:
print "category", category, "values", values
error:
TypeError: loop over non-sequence
What's the most elegant way of doing this?
Thanks!
-Jim
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf