Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17589
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!newsfeed10.multikabel.net!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <arnodel@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.051 |
| X-Spam-Evidence | '*H*': 0.90; '*S*': 0.00; '>>>>': 0.09; 'subject:string': 0.09; 'received:209.85.214.174': 0.13; '[1].': 0.16; 'subject:unicode': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'subject:skip:s 10': 0.18; 'cc:no real name:2**0': 0.20; 'header:In-Reply-To:1': 0.22; 'documented': 0.23; 'cc:2**0': 0.24; 'thanks.': 0.26; 'message-id:@mail.gmail.com': 0.28; 'print': 0.29; 'cc:addr:python.org': 0.29; 'subject:number': 0.30; 'url:library': 0.31; "i've": 0.31; 'received:209.85.214': 0.32; 'url:python': 0.36; '...': 0.36; 'received:google.com': 0.37; 'think': 0.37; 'received:209.85': 0.38; 'url:docs': 0.39; 'url:org': 0.39; "it's": 0.40; 'received:209': 0.40; '2011': 0.61; 'spot': 0.79; 'blind': 0.84; 'otten': 0.84; 'why:': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=40OmeA+JjUEmkLw9ZhYolCZ+laC6/MvEmLAp75wUjHw=; b=TJSekvcdHgc2pl5HvVhqLnK946zuxOdscTvQ6tN/QuWMJzb2WNA0jOQst0x/PHGjGK +EAbk1pR3i6fADEy/eidIV01xNCAsJtJw44TFeu/Vn9K8/5f+yx7bDcCnj4lYbEWp7dh BJD7bAtjAZeSlVkaY9FuqYyHUmhM9qwKvDXXo= |
| MIME-Version | 1.0 |
| In-Reply-To | <jcq9v0$o8f$1@dough.gmane.org> |
| References | <CAJ6cK1bEzksm9A+nGQP2oPN4-HU6S72nmyQWWzhr=y0CJ=c8QQ@mail.gmail.com> <jcq9v0$o8f$1@dough.gmane.org> |
| Date | Tue, 20 Dec 2011 17:04:48 +0000 |
| Subject | Re: Performing a number of substitutions on a unicode string |
| From | Arnaud Delobelle <arnodel@gmail.com> |
| To | Peter Otten <__peter__@web.de> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3869.1324400691.27778.python-list@python.org> (permalink) |
| Lines | 21 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1324400691 news.xs4all.nl 6846 [2001:888:2000:d::a6]:60117 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:17589 |
Show key headers only | View raw
On 20 December 2011 15:35, Peter Otten <__peter__@web.de> wrote:
>>>> escape_map = {
> ... u'\n': u'\\n',
> ... u'\t': u'\\t',
> ... u'\r': u'\\r',
> ... u'\f': u'\\f',
> ... u'\\': u'\\\\'
> ... }
>>>> escape_map = dict((ord(k), v) for k, v in escape_map.items())
>>>> print u"the quick\n brown\tfox
> jumps\\over\\the\\lazy\\dog".translate(escape_map)
> the quick\n brown\tfox jumps\\over\\the\\lazy\\dog
Thanks. I think I've got a blind spot about unicode.translate.
Actually, I know why: it's not properly documented where I look [1].
--
Arnaud
[1] http://docs.python.org/library/stdtypes.html#str.translate
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Performing a number of substitutions on a unicode string Arnaud Delobelle <arnodel@gmail.com> - 2011-12-20 17:04 +0000
csiph-web