[Tutor] How can I escape a pound symbol in my script?

Luke Paireepinart rabidpoobear at gmail.com
Fri Jul 6 07:15:00 CEST 2007


Rikard Bosnjakovic wrote:
> On 7/6/07, Richard Querin <rfquerin at gmail.com> wrote:
>
>   
>> I'm writing a very simple python script which writes out some
>> predefined text to a file (which will later become part of an html
>> file). I need to write out a pound sign '#' to the file and I can't
>> figure out how to escape it. I've tried '\#' and '\u0023', but neither
>> works. How can I do it?
>>     
>
> Works fine here:
>
> $ python -c 'open("foo","w").write("£")'
> $ cat foo
> £
>   
I thought this was very amusing.
If it wasn't meant as a joke, sorry.
I laughed.
> Try to include parts of your code that's not working to this list for
> us to see, there might be some other errors in it.
>   
I second this.  Including code in your post is paramount.
Also, I like to use the word paramount.
-Luke


More information about the Tutor mailing list