Path: csiph.com!usenet.pasdenom.info!news.albasani.net!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.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.034 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'string': 0.09; 'subject:module': 0.09; 'subject:string': 0.09; 'python': 0.11; 'changes': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'instead:': 0.16; 'wrote:': 0.18; 'import': 0.22; 'unicode': 0.24; 'handling': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; '"",': 0.31; 'changed.': 0.31; 'fri,': 0.33; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'skip:s 30': 0.35; 'received:google.com': 0.35; 'received:209': 0.37; 'to:addr :python-list': 0.38; '12,': 0.39; 'to:addr:python.org': 0.39; 'details.': 0.61; 'more': 0.64; 'due': 0.66; 'subject:have': 0.80; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=6WOIuiiW/+odiEPgay2x6+lrMaQjAdGpRf7IW1qXxfU=; b=DHvyHr2cW49No75iy5Eurn4SESbU27xZFG6sBkvjjKtsSYZPGWO/4fehzijNHX7wcI y5CKLinVVWXELqKR3vv6PH/8CpSrhHB/+zLbaRWGFbwtHnpLne1IOmgU9hrvx53yw3Ir IUeo9OYH7Mlgv/h3KozsSRat/eE+AWItfxlFHAgi3+/W7hlesPYwIFrz1Hd77UL5qFV4 BJC9v/dONoLbz25N2NMIOJRHH2xbacHzdyVqT8Glm6xUQJD35XRpD47WCGJlPkV+LXUn Wq9s/zJe21gFG+3FHW5pr3CuF2pb/b6OQQwwrvzREgkqxUbz95fHG3Q9jikAAoIzcvmJ rtyg== MIME-Version: 1.0 X-Received: by 10.220.223.80 with SMTP id ij16mr5510301vcb.28.1365695105465; Thu, 11 Apr 2013 08:45:05 -0700 (PDT) In-Reply-To: <338cca79-08c6-4c6f-89a4-d3a50ece3dee@googlegroups.com> References: <338cca79-08c6-4c6f-89a4-d3a50ece3dee@googlegroups.com> Date: Fri, 12 Apr 2013 01:45:05 +1000 Subject: Re: My string module doesn't have maketrans or translate functions From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365695113 news.xs4all.nl 2661 [2001:888:2000:d::a6]:49865 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43384 On Fri, Apr 12, 2013 at 1:30 AM, Lamb wrote: > import string > s = "string. With. Punctuation?" > out = s.translate(string.maketrans("",""), string.punctuation) Try this instead: import string s = "string. With. Punctuation?" out = s.translate(str.maketrans("", "", string.punctuation)) Due to the changes in string handling (s is a Unicode string in Python 3, not a string of bytes), str.translate() got changed. Check out help(str.maketrans) and help(str.translate) in interactive Python for more details. ChrisA