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.

classification
Title: Difference between open and codecs.open
Type: Stage:
Components: Documentation Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, ezio.melotti, giampaolo.rodola, vstinner
Priority: normal Keywords:

Created on 2013-03-16 10:58 by giampaolo.rodola, last changed 2022-04-11 14:57 by admin.

Messages (2)
msg184303 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2013-03-16 10:58
In Python 2 the distinction between open() and codes.open() was clear because 'encoding' and 'errors' args were provided by codecs.open only.
This is no longer the case in Python 3 since both args are provided also by open().

I'm probably missing something but regardless I think codecs.open doc [1] should be more clear as to when and why (say) codecs.open(file, encoding='utf8', errors='ignore') should be preferred over open(file, encoding='utf8', errors='ignore').

[1] http://docs.python.org/3/library/codecs.html#codecs.open
msg184305 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-03-16 11:13
See also the PEP 400. I proposed (in the alternative) to make codecs.open() somehow an alias to open() (and add codecs.open_stream() for "backward compatibility").
History
Date User Action Args
2022-04-11 14:57:42adminsetgithub: 61639
2020-11-15 18:58:13iritkatrielsetversions: + Python 3.8, Python 3.9, Python 3.10, - Python 3.2, Python 3.3, Python 3.4
2013-03-16 11:13:17vstinnersetnosy: + vstinner
messages: + msg184305
2013-03-16 10:58:59giampaolo.rodolacreate