|
To stupid to live??? Problems with coercing non-numeric types.: msg#00050lang.jython.user
Hi all, Apologies if I'm being too stupid to live, but I'm having problems calling Java methods from within Jython. Specifically I have a method that takes a string one of its parameters. I can call this fined from python if I pass in a string literal: x.myMethod(y, "a string") But, if I pass in a python object: z = Z("a string")
Then I have defined then I get "TypeError: myMethod(): 2nd arg can't be coerced to String". Z is a very simple wrapper class that wraps a string. (In my real code it does more then this, but for this example all it does is wrap a string.) class StringValue:
def __repr__(self):
def __str__(self):
def __coerce__(self, other):
So all of the following work fine with Z: print z #calls z.__str__()
But the x.myMethod(y, z) does not work, and does not call z.__coerce__() either. Any help much appreciated! Thanks in advance,
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Getting a grip on "panels", Jeff Emanuel |
|---|---|
| Next by Date: | Re: To stupid to live??? Problems with coercing non-numeric types., Jack Nutting |
| Previous by Thread: | Getting a grip on "panels", ytcm47-jythonuserslist |
| Next by Thread: | Re: To stupid to live??? Problems with coercing non-numeric types., Jack Nutting |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |