Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #86896

io.open vs. codecs.open

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <fomcl@yahoo.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status UNSURE 0.368
X-Spam-Level ***
X-Spam-Evidence '*H*': 0.46; '*S*': 0.19; 'encoding': 0.05; 'string.': 0.05; 'string': 0.09; '(use': 0.16; 'before.': 0.16; 'skip:l 30': 0.24; 'unicode': 0.24; 'tried': 0.27; 'but': 0.35; 'there': 0.35; 'done': 0.36; 'charset:us-ascii': 0.36; 'hi,': 0.36; 'expected': 0.38; 'system,': 0.38; 'thank': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:98.137': 0.60; 'subject:. ': 0.67; 'between': 0.67; 'received:gq1.yahoo.com': 0.68; 'received:mail.gq1.yahoo.com': 0.68; 'default': 0.69; 'received:98.136': 0.69; 'apart': 0.72; 'discovered': 0.83; 'received:bullet.mail.gq1.yahoo.com': 0.84; 'us?': 0.84; 'medicine,': 0.91; 'education,': 0.96
X-Yahoo-Newman-Property ymail-3
X-Yahoo-Newman-Id 922991.73811.bm@omp1036.mail.gq1.yahoo.com
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1425471137; bh=Reddc28YN2qKs5/hmeAhHGVvuYhyzmSVhtSrv2CXEwo=; h=Message-ID:Date:From:Subject:To:MIME-Version:Content-Type; b=LmUfQ3DljWGnem0xEododPLWUkn16x7nhoP2ZJ+4cbxLNZhJz5O/j284mUVJgsEbiB86wDRldQhdHVq+bYVdlpF89cNQ1avYyVwcXCNLZLUSCaZ0jZaYMUJrvcYLrJpUZCZTRwJspTmVIKcH62SsZB5CmQBTX2NU/Nq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:12:17 -0800
From Albert-Jan Roskam <fomcl@yahoo.com>
Subject io.open vs. codecs.open
To Python <python-list@python.org>
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Mailman-Approved-At Wed, 04 Mar 2015 13:20:37 +0100
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.37.1425471638.21433.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1425471638 news.xs4all.nl 2893 [2001:888:2000:d::a6]:49487
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:86896

Show key headers only | View raw


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 | NextNext in thread | Find similar | Unroll thread


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