The opener parameter of Python 3 open() built-in
Terry Reedy
tjreedy at udel.edu
Tue Sep 4 15:16:38 EDT 2012
More information about the Python-list mailing list
Tue Sep 4 15:16:38 EDT 2012
- Previous message (by thread): The opener parameter of Python 3 open() built-in
- Next message (by thread): The opener parameter of Python 3 open() built-in
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 9/4/2012 8:58 AM, Serhiy Storchaka wrote: > On 04.09.12 04:13, Steven D'Aprano wrote: >> Why does the open builtin need this added complexity? Why not just call >> os.open directly? Or for more complex openers, just call the opener >> directly? >> >> What is the rationale for complicating open instead of telling people to >> just call their opener directly? > > See http://bugs.python.org/issue12797. io.open depends on a function the returns an open file descriptor. opener exposes that dependency so it can be replaced. (Obviously, one could go crazily overboard with this idea.) I believe this is a simple form of dependency injection, though it might be hard to discern from the Java-inspired verbiage of the Wikipedia article. Part of the rationale in the issue is to future-proof io.open from any future needs for alternate fd fetching. It could also be used to decouple a test of io.open from os.open -- Terry Jan Reedy
- Previous message (by thread): The opener parameter of Python 3 open() built-in
- Next message (by thread): The opener parameter of Python 3 open() built-in
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list