Filtering out non-readable characters

George Sakkis gsakkis at rutgers.edu
Sat Jul 16 23:28:02 EDT 2005


"Peter Hansen" <peter at engcorp.com> wrote:

> George Sakkis wrote:
> > "Peter Hansen" <peter at engcorp.com> wrote:
> >>>> Where did you learn that, George?
> >
> > Actually I first read about this in the Cookbook; there are two or three
>  > recipes related to string.translate. As for string.maketrans, it
>  > doesn't do anything special for empty string arguments: ...
>
> I guess so.  I was going to offer to suggest a new paragraph on that
> usage for the docs, but as you and Jp both seem to think the behaviour
> is obvious, I conclude "it's just me" so I suppose I shouldn't bother.

It's only obvious in the sense that _after_ you see this idiom, you can go back to the docs and
realize it's not doing something special; OTOH if you haven't seen it, it's not at all the obvious
solution to "how do I get the first 256 characters". So IMO it should be mentioned, given that
string.translate often operates on the identity table. I think a single sentence is adequate for the
reference docs.

George





More information about the Python-list mailing list