Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43386
| 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 | <lambandme@gmail.com> |
| 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 | <mailman.484.1365695113.3114.python-list@python.org> |
| 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> <mailman.484.1365695113.3114.python-list@python.org> |
| 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 <lambandme@gmail.com> |
| 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 <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> |
| Message-ID | <mailman.485.1365696329.3114.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
My string module doesn't have maketrans or translate functions Lamb <lambandme@gmail.com> - 2013-04-11 08:30 -0700
Re: My string module doesn't have maketrans or translate functions Chris Angelico <rosuav@gmail.com> - 2013-04-12 01:45 +1000
Re: My string module doesn't have maketrans or translate functions Lamb <lambandme@gmail.com> - 2013-04-11 09:05 -0700
Re: My string module doesn't have maketrans or translate functions Chris Angelico <rosuav@gmail.com> - 2013-04-12 02:09 +1000
Re: My string module doesn't have maketrans or translate functions Lamb <lambandme@gmail.com> - 2013-04-11 09:05 -0700
Re: My string module doesn't have maketrans or translate functions Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-04-11 17:56 +0100
Re: My string module doesn't have maketrans or translate functions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-12 00:17 +0000
csiph-web