[Python-Dev] Add transform() and untranform() methods (original) (raw)

Terry Reedy tjreedy at udel.edu
Fri Nov 15 02:10:32 CET 2013


On 11/14/2013 5:32 PM, Victor Stinner wrote:

I don't like the functions codecs.encode() and codecs.decode() because the type of the result depends on the encoding (second parameter). We try to avoid this in Python.

Such dependence is common with arithmetic.

1 + 2 3 1 + 2.0 3.0 1 + 2+0j (3+0j)

sum((1,2,3), 0) 6 sum((1,2,3), 0.0) 6.0 sum((1,2,3), 0.0+0j) (6+0j)

for f in (compile, eval, getattr, iter, max, min, next, open, pow, round, type, vars): type(f(*args)) # depends on the inputs That is a large fraction of the non-class builtin functions.

-- Terry Jan Reedy



More information about the Python-Dev mailing list