On Tue, Aug 30, 2016 at 1:28 AM, Random832 <random...@fastmail.com> wrote: > On Mon, Aug 29, 2016, at 11:14, Chris Angelico wrote: >> Please don't. :) This is something that belongs in the application; >> it's somewhat hacky, and I don't see any benefit to it going into the >> language. For one thing, I could well imagine making the fallback >> encoding configurable (it isn't currently, but it could easily be), >> and that doesn't really fit into the Python notion of error handler. > > Well, yeah, if anything implementing it as an error handler is a hack, I > just meant it's just the least hacky way I can think that fits in the > size "half a dozen lines". > >> For another, this is a fairly rare concept - I don't see dozens of >> programs out there using the exact same strange logic, and even if >> there were, there'd be small differences > > That is actually an argument in favor of putting it in the stdlib, > assuming few of those small differences are truly considered and > intentional. The main thrust of my post was that this is one of the > things that's harder than it sounds to get right due to edge cases, just > like the clip/clamp function being discussed last month.
Fair enough. If this were something that a lot of programs wanted, then yeah, there'd be good value in stdlibbing it. Character encodings ARE hard to get right, and this kind of thing does warrant some help. But I think it's best not done in core - at least, not until we see a lot more people doing the same :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list