python-distilled icon indicating copy to clipboard operation
python-distilled copied to clipboard

10.1 bytes.maketrans() / str.translate() signature mix-up

Open wildekat opened this issue 2 years ago • 0 comments

In section 10.1, Table 10.1 "Operations on Bytes and Bytearrays":

s.maketrans(x [, y [, z]]) Makes a translation table for s.translate().

For bytes and bytearray, maketrans() takes two arguments: maketrans(frm, to, /)

And further down, in Table 10.9 "String Operators and Methods", you have:

s.translate(table [, deletechars]) Translates a string using a character translation table table, removing characters in deletechars.

According to the docs, the optional second parameter (delete) is a bytes/bytearray thing, while str.translate only takes one (mandatory) argument: translate(self, table, /)

wildekat avatar Mar 13 '23 19:03 wildekat