Josiah Carlson wrote: > How are users confused? Users do
py> "Martin v. Löwis".encode("utf-8") Traceback (most recent call last): File "<stdin>", line 1, in ? UnicodeDecodeError: 'ascii' codec can't decode byte 0xf6 in position 11: ordinal not in range(128) because they want to convert the string "to Unicode", and they have found a text telling them that .encode("utf-8") is a reasonable method. What it *should* tell them is py> "Martin v. Löwis".encode("utf-8") Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: 'str' object has no attribute 'encode' > bytes.encode CAN only produce bytes. I don't understand MAL's design, but I believe in that design, bytes.encode could produce anything (say, a list). A codec can convert anything to anything else. > If some users > can't understand this (passing different arguments to a function may > produce different output), It's worse than that. The return *type* depends on the *value* of the argument. I think there is little precedence for that: normally, the return values depend on the argument values, and, in a polymorphic function, the return type might depend on the argument types (e.g. the arithmetic operations). Also, the return type may depend on the number of arguments (e.g. by requesting a return type in a keyword argument). > then I think that some users are broken beyond repair. Hmm. I'm speechless. Regards, Martin _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com