Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'elif': 0.05; 'subject:Python': 0.06; 'cc:addr:python-list': 0.11; 'def': 0.12; 'jan': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:More': 0.16; 'subject:Unicode': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; "d'aprano": 0.31; 'steven': 0.31; 'subject:About': 0.31; 'way?': 0.31; "i'd": 0.34; 'but': 0.35; 'received:google.com': 0.35; 'rather': 0.38; 'subject:"': 0.60; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=hclqOZscy2UTl8imlAB6J0hTDT+HetEcp5HuJLyhryY=; b=TxLjcSaorrvl8KpIVphxuCrT+lHXODQRKYfLXY6tW0JmHeaP5MUEi+8RSdrupxDLME LIqoboyUqm6HTFF/OAABpHhmJSeTV/0ZzcxUjwkOlES1Jd5mCYHjHFNFQdq/74c09155 KcOgMFuHbe0b5fhydiIV5UMxpGFAX9AdAusQ8iQG4QstyQ0fruTWL/Q3kD52hNkXLz2C yAnJgE35Yi//9b5oU8uEfxGG1NNNxgP3xiH7FGuqE7lSlmmtis/4H//BihDYHDZJPd0w nRjRb1D9JUwStX0pj/HWimAhLD+wsml1gGE8WugnHz4v9Wt5jLwgPGH5kjQ9J5Kiu/hs lNsg== MIME-Version: 1.0 X-Received: by 10.68.162.66 with SMTP id xy2mr8430636pbb.46.1389025817486; Mon, 06 Jan 2014 08:30:17 -0800 (PST) In-Reply-To: <52cad8b4$0$29984$c3e8da3$5496439d@news.astraweb.com> References: <52CA13BD.4050708@stoneleaf.us> <52cad8b4$0$29984$c3e8da3$5496439d@news.astraweb.com> Date: Tue, 7 Jan 2014 03:30:17 +1100 Subject: Re: "More About Unicode in Python 2 and 3" From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389025822 news.xs4all.nl 2893 [2001:888:2000:d::a6]:50220 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63295 On Tue, Jan 7, 2014 at 3:24 AM, Steven D'Aprano wrote: > If you don't want to use the codec, you can do it by hand: > > def rot13(astring): > result = [] > for c in astring: > i = ord(c) > if ord('a') <= i <= ord('m') or ord('A') <= i <= ord('M'): > i += 13 > elif ord('n') <= i <= ord('z') or ord('N') <= i <= ord('Z'): > i -= 13 > result.append(chr(i)) > return ''.join(result) > > But why would you want to do it the slow way? Eww. I'd much rather use .translate() than that :) ChrisA