From: Brad C. <bc...@vi...> - 2002-03-26 19:31:27
|
As the one that asked Anythony about this (mis?)feature on the jpublish list, I'd like to add my support to his request. I'd have done it directly except that I'm so new to python that I'd thought this was my fault. PS: The token (+ vs , vs nothing) isn't important. What *is* is that the result winds up as a string, not array, tuple, etc. PPS: Probably harder, supporting expansion of variables within strings ala' perl would immediately make python a favorite. The ${variable}s workaround that was offered here earlier is a bit obscure for heavily used stuff like expanding variable information into html template files. See http://virtualschool.edu/jwaa under Mls (multi line preprocessor), velocity, or JSP/ASP for workarounds to the same problem in Java. This really "should" be supported by the language, not outside as in mls, velocity, or jsp. Like this: title = "my title" print ''' <html> <head> <title>$title</title> </head> </html> ''' Ideally, this should work for any expression (variables, subroutine calls, arrays, tuples, etc). As I recall, perl didn't do all of these right. Don't recall exactly; I haven't used perl in some years. At 1:23 PM -0500 3/26/02, Anthony Eden wrote: >Currently, in Jython, using any arbitrary Java object aside from a >java.lang.String, the following fails: > > print "text" + obj > >With the message: TypeError: __add__ nor __radd__ defined for these operands > >But the following works: > > print "test", obj > >Would the Jython implementers consider modifying the PyJavaInstance >class with something similar to: > > public PyObject __add__(PyObject object) { > return __str__ + object.__str__(); > } > >So that the + notation as used in Java works properly? I am not >sure if the code I provided above is correct as I am >not intimately familiar with the Jython source. I am also not sure >if this has been discussed before: the mailing list >archives provided at the Jython.org site do not have search >facilities (AFAICT) and I was unable to find anything about >it in my mail application (back to 7/21/2001), so I apologize ahead >of time if it has. > >Sincerely, >Anthony Eden > > >_______________________________________________ >Jython-users mailing list >Jyt...@li... >https://lists.sourceforge.net/lists/listinfo/jython-users -- Brad Cox, PhD; bc...@vi... 703 361 4751 o For industrial age goods there were checks and credit cards. For everything else there is http://virtualschool.edu/mybank o Java Interactive Learning Environment http://virtualschool.edu/jile o Java Web Application Architecture: http://virtualschool.edu/jwaa |