Re: How to read strings cantaining escape character from a file and use it as escape sequences?

2007-12-02 Thread Duncan Booth
John Machin <[EMAIL PROTECTED]> wrote: > Hmmm ... the encode is documented as "Produce a string that is > suitable as Unicode literal in Python source code", but it *isn't* > suitable. A Unicode literal is u'blah', this gives just blah. Worse, > it leaves the caller to nut out how to escape apostr

Re: How to read strings cantaining escape character from a file and use it as escape sequences?

2007-12-01 Thread Bjoern Schliessmann
John Machin wrote: > Amazing what you can find in obscure corners of the obscure docs! > BTW, how many folks know what "bijective" means ? Everyone that can read and is smart enough to enter "bijective" into Wikipedia search. Regards, Björn -- BOFH excuse #25: Decreasing electron flux --

Re: How to read strings cantaining escape character from a file and use it as escape sequences?

2007-12-01 Thread John Machin
On Dec 2, 2:33 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > slomo <[EMAIL PROTECTED]> wrote: > print line > > \u0050\u0079\u0074\u0068\u006f\u006e > > > But I want to get a string: > > > "\u0050\u0079\u0074\u0068\u006f\u006e" > > > How do you make it? > > line.decode('unicode-escape') Amazin

Re: How to read strings cantaining escape character from a file and use it as escape sequences?

2007-12-01 Thread James Matthews
Also alot of times in the interactive interpeter it will show you charater codes! On Dec 1, 2007 6:04 PM, slomo <[EMAIL PROTECTED]> wrote: > WOW! Great! Thanks, Duncan. > > > On 12월2일, 오전12시33분, Duncan Booth <[EMAIL PROTECTED]> wrote: > > slomo <[EMAIL PROTECTED]> wrote: > > print line > > >

Re: How to read strings cantaining escape character from a file and use it as escape sequences?

2007-12-01 Thread slomo
WOW! Great! Thanks, Duncan. On 12월2일, 오전12시33분, Duncan Booth <[EMAIL PROTECTED]> wrote: > slomo <[EMAIL PROTECTED]> wrote: > print line > > \u0050\u0079\u0074\u0068\u006f\u006e > > > But I want to get a string: > > > "\u0050\u0079\u0074\u0068\u006f\u006e" > > > How do you make it? > > line.d

Re: How to read strings cantaining escape character from a file and use it as escape sequences?

2007-12-01 Thread Duncan Booth
slomo <[EMAIL PROTECTED]> wrote: print line > \u0050\u0079\u0074\u0068\u006f\u006e > > But I want to get a string: > > "\u0050\u0079\u0074\u0068\u006f\u006e" > > How do you make it? > line.decode('unicode-escape') -- http://mail.python.org/mailman/listinfo/python-list

How to read strings cantaining escape character from a file and use it as escape sequences?

2007-12-01 Thread slomo
How to read strings cantaining escape character from a file and use it as escape sequences? for example, a file 'unicodes.txt' has contents: \u0050\u0079\u0074\u0068\u006f\u006e Now, >>> file = open('unicodes.txt') >>> line = file.readline() >>> l