I have two questions about strings. How do I convert an integer to a string? I want to concatinate it with a string as such: <!--#var "'c' + _['sequence-item']"--> where sequence-item is an integer. This got me looking at the "Alternate Python String Format Syntax" (page 4, DTML user guide). It seems like it should do what I want but I can't make it work. Where do these get put? Can they be in expr=""? or are they loose in the HTML? Thanks, Phil A
On Thu, 6 May 1999, Philip Aylesworth wrote:
How do I convert an integer to a string?
In Python, backticks turn any expression into a string. So this--
<!--#var "'c' + _['sequence-item']"-->
--which probably gives you an incompatible types exception, would work if it were expressed like this: <!--#var "'c' + `_['sequence-item']`"--> Mike. -- --- | Mike Pelletier Work: 519-746-1607 /opeware! | Software Developer Home: 519-725-7710 --- | mike@zopeware.com Fax: 519-746-7566 http://www.zopeware.com | Zopeware is not endorsed by Digital Creations
Mike Pelletier wrote:
On Thu, 6 May 1999, Philip Aylesworth wrote:
How do I convert an integer to a string?
<!--#var "'c' + `_['sequence-item']`"-->
This worked but I get quotes in the final string. eg. c'1' I haven't seen this back tick idea yet, but I haven't delved to deep into Python yet either. :)
<!--#var "'c' + _.str(_['sequence-item'])"-->
This did the trick. I even found it in the DTML users guide! Seems like I should reread it cover to cover every time I need to know something. It is all in there some where! Thanks both! Phil A.
On Thu, 6 May 1999, Philip Aylesworth wrote:
<!--#var "'c' + `_['sequence-item']`"-->
This worked but I get quotes in the final string. eg. c'1' I haven't seen this back tick idea yet, but I haven't delved to deep into Python yet either. :)
I'm surprised. It doesn't result in embedded quotes in the interpreter. Can anyone explain this? Is it intentional? Mike. -- --- | Mike Pelletier Work: 519-746-1607 /opeware! | Software Developer Home: 519-725-7710 --- | mike@zopeware.com Fax: 519-746-7566 http://www.zopeware.com | Zopeware is not endorsed by Digital Creations
participants (2)
-
Mike Pelletier -
Philip Aylesworth