[portland] Generating .tex From Python Code

Adam Lowry adam at therobots.org
Fri Apr 4 00:38:38 CEST 2008


If you want to avoid backslashes being treated as control chars in  
strings, prefix them with r:
str = r"[\%#]*"
I often use this with regular expressions.

On Apr 3, 2008, at 3:19 PM, Jesse Hallett <hallettj at gmail.com> wrote:

> Since backslashes are generally parsed as escape characters, I believe
> you would get the right results if you replaced all of the backslashes
> (\) in strings with double backslashes (\\).
>
> Be aware that some languages treat backslashes as escape characters in
> strings enclosed in double quotes (") but in strings enclosed in  
> single
> quotes('). I don't remember whether Python does this; but if it does,
> then another solution would be to replace all of your double quotes  
> with
> single quotes.
>
> Cheers,
> Jesse
>
> Rich Shepard wrote:
>> On Thu, 3 Apr 2008, Rich Shepard wrote:
>>
>>> I made python mistakes in the code? For example, why is the last  
>>> line of the
>>> preamb comment truncated by two letters? Why are other letters  
>>> missing,
>>
>>   OK. I suspect that \t it taken as a tab rather than a literal,  
>> and that \b
>> is seen as bold rather than as a literal.
>>
>>   Clues welcome!
>>
>> Rich
>>
> _______________________________________________
> Portland mailing list
> Portland at python.org
> http://mail.python.org/mailman/listinfo/portland


More information about the Portland mailing list