On Sat, Apr 7, 2012 at 8:30 AM, Nicholas Cole wrote:
> On Sat, Apr 7, 2012 at 12:10 AM, Ian Kelly wrote:
> import codecs
> codecs.getdecoder('unicode_escape')(s)[0]
>> 'Hello: this is a test'
>>
>> Cheers,
>> Ian
>
> Thanks, Ian. I had assumed that if a unicode string didn't have a
> .de
On Sat, Apr 7, 2012 at 12:10 AM, Ian Kelly wrote:
import codecs
codecs.getdecoder('unicode_escape')(s)[0]
> 'Hello: this is a test'
>
> Cheers,
> Ian
Thanks, Ian. I had assumed that if a unicode string didn't have a
.decode method, then I couldn't use a decoder on it, so it hadn't
occu
On Fri, Apr 6, 2012 at 11:52 AM, Nicholas Cole wrote:
> In Python 2 given the following raw string:
>
s = r"Hello\x3a this is a test"
>
> the escaping could be removed by use of the following:
>
s.decode('string_escape')
>
> In Python 3, however, the only way I can see to achieve the sam
On Fri, Apr 6, 2012 at 4:19 PM, Terry Reedy wrote:
> I actually thought of that, but assumed that adding enclosing quotes would
> be safe (or that the OP trusted the string). After sending, I realized that
> if Nasty Hacker guessed that the string would be so augmented, then it would
> not be safe
On 4/6/2012 6:05 PM, Cameron Simpson wrote:
On 06Apr2012 16:57, Terry Reedy wrote:
| On 4/6/2012 1:52 PM, Nicholas Cole wrote:
| bytes(s, 'utf-8').decode('unicode_escape')
|>
|> This seems very ugly (and slightly 'wrong'). Is there no way to do
|> this without using bytes? Have I mis
On 06Apr2012 16:57, Terry Reedy wrote:
| On 4/6/2012 1:52 PM, Nicholas Cole wrote:
| > In Python 2 given the following raw string:
| >
| s = r"Hello\x3a this is a test"
| >
| > the escaping could be removed by use of the following:
| >
| s.decode('string_escape')
|
| > In Python 3, howe
On 4/6/2012 1:52 PM, Nicholas Cole wrote:
In Python 2 given the following raw string:
s = r"Hello\x3a this is a test"
the escaping could be removed by use of the following:
s.decode('string_escape')
In Python 3, however, the only way I can see to achieve the same
result is to convert int