Mahmoud Hashemi added the comment:

Martin, it sounds that way because that is what is being proposed: "Merging and 
simplifying the two modes". Given the existence of .decode() on bytestrings, 
the only objects that generally need decoding in Python 2 and 3, the existence 
of str/unicode's second mode constitutes a design bug.

Without a doubt, Python has frequently preferred convenient idioms over EAFP. 
Look at dict.get for an excellent example of defaults being used instead of 
forcing users to catch KeyErrors. That conversation could have gone a different 
way, but Python is better off having stuck to its pragmatic roots.

In answer to your questions, Martin, 1) I'd expect str(b"123", encoding=None) 
to do the same thing as str(b"123")  and 2) I'd expect str(obj) behavior to 
continue to depend on whether the object passed is string-like. Python is a 
duck-typed, dynamic language, and dynamic languages are most powerful when 
their core types reflect usability. Consistency is one of the foremost factors 
of usability, and having to frequently switch between two call patterns of the 
str constructor feels inconsistent and unusable.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24019>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to