Re: Micro-PEP: str.translate(None) to mean identity translation
- From: "M.E.Farmer" <mefjr75@xxxxxxxxxxx>
- Date: 29 Apr 2005 21:27:18 -0700
Bengt Richter wrote:
> Just thought None as the first argument would be both handy and
mnemonic,
> signifying no translation, but allowing easy expression of deleting
characters,
> e.g.,
>
> s = s.translate(None, 'badcharshere')
>
> Regards,
> Bengt Richter
What's wrong with :
s = s.replace('badchars', "")
It seems obvious to replace a char ( to me anyway ) with a blank
string, rather than to 'translate' it to None.
I am sure you have a reason what am I missing ?
M.E.Farmer
.
- Follow-Ups:
- Re: Micro-PEP: str.translate(None) to mean identity translation
- From: Bengt Richter
- Re: Micro-PEP: str.translate(None) to mean identity translation
- From: Peter Otten
- Re: Micro-PEP: str.translate(None) to mean identity translation
- References:
- Micro-PEP: str.translate(None) to mean identity translation
- From: Bengt Richter
- Micro-PEP: str.translate(None) to mean identity translation
- Prev by Date: Re: Fast plotting?
- Next by Date: Re: Python Challenge ahead [NEW] for riddle lovers
- Previous by thread: Re: Micro-PEP: str.translate(None) to mean identity translation
- Next by thread: Re: Micro-PEP: str.translate(None) to mean identity translation
- Index(es):
Relevant Pages
|