New submission from Nick Coghlan <ncogh...@gmail.com>: (This proposes a new builtin, so may need to become a PEP)
A common programming task is "I want to process this text file, I know it's in an ASCII compatible encoding, I don't know which one specifically, but I'm only manipulating the ASCII parts so it doesn't matter". In Python 2, you handle that task by doing: f = open(fname) The non-ASCII parts are then carried along as 8-bit bytes and reproduced faithfully when written back out. In Python 3, you handle it by doing: f = open(fname, encoding="ascii", errors="surrogateescape") The non-ASCII parts are then carried along as code points in the Unicode Private Use Area and reproduced faithfully when written back out. It would be significantly more friendly to beginners (and migrants from Python 2) if the following shorthand spelling was available out of the box: f = open_ascii(fname) ---------- messages: 153164 nosy: ncoghlan priority: normal severity: normal status: open title: Add open_ascii() builtin _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13997> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com