This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mahmoud
Recipients eric.smith, ezio.melotti, mahmoud, martin.panter, vstinner
Date 2015-04-22.00:57:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1429664262.81.0.187869151611.issue24019@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-04-22 00:57:42mahmoudsetrecipients: + mahmoud, vstinner, eric.smith, ezio.melotti, martin.panter
2015-04-22 00:57:42mahmoudsetmessageid: <1429664262.81.0.187869151611.issue24019@psf.upfronthosting.co.za>
2015-04-22 00:57:42mahmoudlinkissue24019 messages
2015-04-22 00:57:42mahmoudcreate