Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'string': 0.09; 'subject:module': 0.09; 'subject:string': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'changes': 0.15; '11:45:05': 0.16; 'instead:': 0.16; 'thursday,': 0.16; 'wrote:': 0.18; 'import': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'unicode': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'handling': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; '"",': 0.31; 'changed.': 0.31; 'thanks!': 0.32; 'received:209.85': 0.35; 'skip:s 30': 0.35; 'but': 0.35; 'received:google.com': 0.35; "didn't": 0.36; 'received:209': 0.37; 'called': 0.40; 'details.': 0.61; 'more': 0.64; 'due': 0.66; 'subject:have': 0.80; '2013': 0.98 X-Received: by 10.182.152.34 with SMTP id uv2mr152055obb.23.1365696318629; Thu, 11 Apr 2013 09:05:18 -0700 (PDT) Newsgroups: comp.lang.python Date: Thu, 11 Apr 2013 09:05:18 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=160.39.203.232; posting-account=msTAaAoAAACLSzBPHlPRAsWf8pU1gMGm References: <338cca79-08c6-4c6f-89a4-d3a50ece3dee@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 160.39.203.232 MIME-Version: 1.0 Subject: Re: My string module doesn't have maketrans or translate functions From: Lamb To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org 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: , Message-ID: Lines: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365696329 news.xs4all.nl 2582 [2001:888:2000:d::a6]:54398 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43386 Thanks! It worked! But why didn't I see functions : translate(), maketrans(), rstrip(), etc. listed when I called print(dir(string))? On Thursday, April 11, 2013 11:45:05 AM UTC-4, Chris Angelico 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