On 23/01/2014 20:10, Peter Otten wrote:
Vincent Davis wrote:

On Thu, Jan 23, 2014 at 12:02 PM, Peter Otten <__pete...@web.de> wrote:

I just noted that the first Python loop can be eliminated:


Oops, I forgot to paste

import string
def chars(a, b):
     return "".join(map(chr, range(a, b)))
_mapping = string.maketrans(chars(0, 10), chars(48, 58))


FTR string.maketrans is gone from Python 3.2+. Quoting from http://docs.python.org/dev/whatsnew/3.2.html#porting-to-python-3-2 "The previously deprecated string.maketrans() function has been removed in favor of the static methods bytes.maketrans() and bytearray.maketrans(). This change solves the confusion around which types were supported by the string module. Now, str, bytes, and bytearray each have their own maketrans and translate methods with intermediate translation tables of the appropriate type."

--
My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to