Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #86896
| Date | 2015-03-04 04:12 -0800 |
|---|---|
| From | Albert-Jan Roskam <fomcl@yahoo.com> |
| Subject | io.open vs. codecs.open |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.37.1425471638.21433.python-list@python.org> (permalink) |
Hi, Is there a (use case) difference between codecs.open and io.open? What is the difference? A small difference that I just discovered is that codecs.open(somefile).read() returns a bytestring if no encoding is specified*), but a unicode string if an encoding is specified. io.open always returns a unicode string. *) I had never tried that before. I would have expected that encoding would default to e.g locale.getpreferredencoding(). Thank you! Regards, Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
io.open vs. codecs.open Albert-Jan Roskam <fomcl@yahoo.com> - 2015-03-04 04:12 -0800
Re: io.open vs. codecs.open Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-05 06:56 +1100
Re: io.open vs. codecs.open Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-03-04 20:15 +0000
Re: io.open vs. codecs.open Albert-Jan Roskam <fomcl@yahoo.com> - 2015-03-06 13:48 +0000
csiph-web