Re: How to write raw strings to Python

2017-07-05 Thread Pavol Lisy
On 7/5/17, Binary Boy wrote: > On Wed, 05 Jul 2017 20:37:38 +0300, Jussi Piitulainen wrote: >> Sam Chats writes: >> >> > On Wednesday, July 5, 2017 at 9:09:18 PM UTC+5:30, Grant Edwards wrote: >> >> On 2017-07-05, Sam Chats wrote: >> >> >> >> > I want to

Re: How to write raw strings to Python

2017-07-05 Thread Jussi Piitulainen
Binary Boy writes: > On Wed, 05 Jul 2017 20:37:38 +0300, Jussi Piitulainen wrote: >> Sam Chats writes: >> >> > On Wednesday, July 5, 2017 at 9:09:18 PM UTC+5:30, Grant Edwards wrote: >> >> On 2017-07-05, Sam Chats wrote: >> >> >> >> > I want to write, say, 'hello\tworld'

Re: How to write raw strings to Python

2017-07-05 Thread Binary Boy
On Wed, 05 Jul 2017 20:37:38 +0300, Jussi Piitulainen wrote: > Sam Chats writes: > > > On Wednesday, July 5, 2017 at 9:09:18 PM UTC+5:30, Grant Edwards wrote: > >> On 2017-07-05, Sam Chats wrote: > >> > >> > I want to write, say, 'hello\tworld' as-is to a file, but doing > >>

Re: How to write raw strings to Python

2017-07-05 Thread Jussi Piitulainen
Sam Chats writes: > On Wednesday, July 5, 2017 at 9:09:18 PM UTC+5:30, Grant Edwards wrote: >> On 2017-07-05, Sam Chats wrote: >> >> > I want to write, say, 'hello\tworld' as-is to a file, but doing >> > f.write('hello\tworld') makes the file look like: >> [...] >> > How can

Re: How to write raw strings to Python

2017-07-05 Thread Sam Chats
On Wednesday, July 5, 2017 at 9:09:18 PM UTC+5:30, Grant Edwards wrote: > On 2017-07-05, Sam Chats wrote: > > > I want to write, say, 'hello\tworld' as-is to a file, but doing > > f.write('hello\tworld') makes the file look like: > [...] > > How can I fix this? > > That

Re: How to write raw strings to Python

2017-07-05 Thread Grant Edwards
On 2017-07-05, Sam Chats wrote: > I want to write, say, 'hello\tworld' as-is to a file, but doing > f.write('hello\tworld') makes the file look like: [...] > How can I fix this? That depends on what you mean by "as-is". Seriously. Do you want the single quotes in the file?

Re: How to write raw strings to Python

2017-07-05 Thread Thomas Jollans
On 2017-07-05 17:09, Sam Chats wrote: > > Thanks, but I've tried something similar. Actually, I want to convert a > string which I receive from a NNTP server to a raw string. So if I try > something like: > raw = r"%s" % string_from_server > You may me looking for repr()

Re: How to write raw strings to Python

2017-07-05 Thread Sam Chats
On Wednesday, July 5, 2017 at 8:22:13 PM UTC+5:30, Stephen Tucker wrote: > Sam, > > You use > > f.write(r'hello\tworld') > > The r in front of the string stands for raw and is intended to switch off > the escape function of the backslash in the string. It works fine so long > as the string

Re: How to write raw strings to Python

2017-07-05 Thread Stephen Tucker
Sam, You use f.write(r'hello\tworld') The r in front of the string stands for raw and is intended to switch off the escape function of the backslash in the string. It works fine so long as the string doesn't end with a backslash, as in f.write('hello\tworld\') If you try this, you get an

Re: How to write raw strings to Python

2017-07-05 Thread Stephen Tucker
Sam, You use r'hello\tworld' The r in front of the string stands for raw and it is intended to switch off the normal escape function of a backslash. It works fine so long as the string doesn't end with a backslash. If you end the string with a backslash, as in r'hello\tworld\' you get an

How to write raw strings to Python

2017-07-05 Thread Sam Chats
I want to write, say, 'hello\tworld' as-is to a file, but doing f.write('hello\tworld') makes the file look like: hello world How can I fix this? Thanks in advance. Sam -- https://mail.python.org/mailman/listinfo/python-list