'string'.strip(chars)-like function that removes from the middle?
Sion Arrowsmith
siona at chiark.greenend.org.uk
Tue Jun 17 06:02:19 EDT 2008
In article <g37pur$k5o$00$1 at news.t-online.com>,
Peter Otten <__peter__ at web.de> wrote:
>Terry Reedy wrote:
>> >>> 'abcde'.translate(str.maketrans('','','bcd'))
>> 'ae'
>You should mention that you are using Python 3.0 ;)
>The 2.5 equivalent would be
>
>>>> u"abcde".translate(dict.fromkeys(map(ord, u"bcd")))
>u'ae'
Only if you're using Unicode:
>>> 'abcde'.translate(string.maketrans('',''), 'bcd')
'ae'
>>> sys.version_info
(2, 4, 4, 'final', 0)
--
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
"Frankly I have no feelings towards penguins one way or the other"
-- Arthur C. Clarke
her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
More information about the Python-list
mailing list