[Python-Dev] Deprecate codecs.open() and StreamWriter/StreamReader (original) (raw)

Vinay Sajip vinay_sajip at yahoo.co.uk
Sat May 28 16:57:15 CEST 2011


Victor Stinner <victor.stinner haypocalc.com> writes:

It's difficult for an user to choose between between open() and codecs.open().

Is it? How about the following decision process?

If writing code for Python 3.x only, use open().

If writing code which has to work under both Python 2.x and 3.x, use codecs.open().

BTW I have written code using StreamReader and StreamWriter in the past, though it may not have been published on the Internet. Python is used a lot by companies for internal systems. Such code is seldom published on the Internet, so it seems that there's no real way of knowing how much StreamReader/StreamWriter are used.

When looking at porting projects to Python 3.x, I've always adopted a single code-base approach for 2.x and 3.x, as I feel it's the path of least ongoing maintenance and hence (in my experience) the path of least resistance to providing 3.x support. Though of course I've no objection to implementing their functionality in the most efficient way possible (which may well be TextIOWrapper), IMO deprecating StreamReader/StreamWriter will make 2.x/3.x portability harder to achieve, and so seems a step too far.

Regards,

Vinay Sajip



More information about the Python-Dev mailing list