Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43387

Re: My string module doesn't have maketrans or translate functions

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.035
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'string': 0.09; 'subject:module': 0.09; 'subject:string': 0.09; 'bytes).': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'module': 0.19; 'bytes': 0.24; 'unicode': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'class': 0.32; 'thanks!': 0.32; 'checking': 0.33; 'fri,': 0.33; 'basic': 0.35; 'but': 0.35; 'received:google.com': 0.35; "didn't": 0.36; 'should': 0.36; 'being': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; '12,': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'more': 0.64; '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=QoDYXDc5UtCrNu8ozJqnb96eahFPUe1ySUpLgxm94f4=; b=GwUTtQOR8GlglP1NcDIN1+ViNU14zPnBAlDm3YDT7cFxk5/vE5DHRKucFE8Lg3kNfR afWIDEoeCayHM9Ze++b904Eq/rC1sNMeYlr/40LvL6FFBDk31kULqUi3U6ayIZNnLpAO I+i/qrLrrbkvOQK2xhKnhWfKXLLCvcV1jdqcLDZweKmsylKslFU68fDn3PKx3WpThIgA 9X+9PcQegTwgQw7RMqczJR1dBCVhmTAUG9XYvXJ6lgYDs9qjHe5E5lngg7zG8mgMq5SK o33qEBnR3PMTXJXkbGXvC/CJgECBKai+3pY+VDQBtG8i5z6D1M57Fzzo+VSYOBPMWAej J+2w==
MIME-Version 1.0
X-Received by 10.52.111.130 with SMTP id ii2mr4701586vdb.111.1365696579409; Thu, 11 Apr 2013 09:09:39 -0700 (PDT)
In-Reply-To <5dbca83a-f976-4582-8022-8f8c67f759e6@googlegroups.com>
References <338cca79-08c6-4c6f-89a4-d3a50ece3dee@googlegroups.com> <mailman.484.1365695113.3114.python-list@python.org> <5dbca83a-f976-4582-8022-8f8c67f759e6@googlegroups.com>
Date Fri, 12 Apr 2013 02:09:39 +1000
Subject Re: My string module doesn't have maketrans or translate functions
From Chris Angelico <rosuav@gmail.com>
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 <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.486.1365696582.3114.python-list@python.org> (permalink)
Lines 9
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1365696582 news.xs4all.nl 2696 [2001:888:2000:d::a6]:57903
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43387

Show key headers only | View raw


On Fri, Apr 12, 2013 at 2:05 AM, Lamb <lambandme@gmail.com> wrote:
> Thanks! It worked! But why didn't I see functions : translate(), maketrans(), rstrip(), etc. listed when I called print(dir(string))?

Because they're not in the string module any more - they're methods on
str (and bytes). Try checking out dir(str) - str being the class of
your basic Unicode string now, rather than being the type of a string
of bytes - and you should see them all.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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