[mod_python] line continuned operator...\

Graham Dumpleton graham.dumpleton at gmail.com
Mon Aug 4 21:18:19 EDT 2008


Bounced back to mailing list. Please use reply-all and keep followups on list.

2008/8/5  <remember.pol at gmail.com>:
> Ah.. I realized because the whole page is wrapped in a req.write.
> :)
>
> Thanks!
> Also, is there a way to replace string variables within a string
> literal in either Python or mod_python/psp functionality?
>
> It's done in PHP like so:
>
> $hi = 'hello';
> $my_str = '$hi world';
>
> whould would set $my_str to 'hello world'
>
> On 8/4/08, Graham Dumpleton <graham.dumpleton at gmail.com> wrote:
>> 2008/8/5 . <remember.pol at gmail.com>:
>>> Well, I'm curious as to whether anyone could please properly explain
>>> this to me ...
>>>
>>> Any time I end a line in a .psp (mod_python) file with a single
>>> backslash, this character is not rendered in the final HTML when the
>>> page is requested through the HTTPD (Apache)..
>>>
>>> If the backslash is placed anywhere other than as the extreme last
>>> character on a line, then it is rendered as expected.
>>>
>>> In order to have the backslash rendered at the end of a .psp line it
>>> actually needs to be escaped by proceeding it with another backslash.
>>>
>>> Note, this is _not_ within a code-delimited block (<% %>).
>>>
>>> Also, not only is it not rendered but it actually results in the
>>> newline following the backslash to be removed, resulting in the two
>>> rendered HTML lines to actually be one.
>>>
>>> I find this strange because in a sense the operator is functioning
>>> ``as defined''... but under what scope?  Simply because I have it in a
>>> .psp file?
>>>
>>> This doesn't happen in .php or .html files. And again I need to
>>> reiterate this is _NOT_ within a python <% %> block.
>>>
>>> Finally, this seems to be the only existing escapable character.
>>>
>>> I tried placing \t and \n in the file (and yes, even right at the
>>> extreme end of a line), and they simply show up as \t and \n in the
>>> rendered HTML. (Not the actual ASCII character equivalents)
>>>
>>> Any ideas?
>>
>> Enable PythonDebug and .psp_ extension and look at generated source
>> code. Because Python code is being generated, what is probably being
>> produced is:
>>
>>   """dsfdsaasasfd\
>> asdasdfasfd"""
>>
>> Python is then interpreting it as line continuation character.
>>
>> Details of line continuation in:
>>
>>   http://www.network-theory.co.uk/docs/pytut/Strings.html
>>
>> Other than that, can't find anything in code which is specifically
>> dealing with backslash.
>>
>> Graham
>>
>


More information about the Mod_python mailing list