On 17/05/2020 19:43, David Mertz wrote:
I believe boolean mode switches are usually a bad design for Python. Not always, there are exceptions like open().
Actually, open() is a really bad example. It does have a flag, "closefd" which if False and a file descriptor was passed in rather than a filename leaves the file descriptor open when the file object is closed. The mode parameter than most people will be thinking about really is a mode parameter, not a flag; it folds together four basic opening modes (read, write, exclusive, append), an update flag and a text/binary flag. The former universal newlines flag got separated out to be a mode parameter all its own when it turned out not to be a simple flag after all. I seem to remember that separation being somewhat painful... -- Rhodri James *-* Kynesim Ltd