[New-bugs-announce] [issue42543] case sensitivity in open() arguments

Sean Grogan report at bugs.python.org
Wed Dec 2 11:09:30 EST 2020

New submission from Sean Grogan <sean.grogan at gmail.com>:

I was stuck on a problem today using an open statement where I was trying to open a file for writing


    with open("RESULTS.CSV", "W") as csvfile:
        csvwriter = csv.writer(csvfile)
        csvwriter.writerow(["X", "Y"])

I did not notice I had the mode W in upper case. I am not sure if there is a legacy reason for only allowing lower case arguments here but I think a quick note in the documentation that it's case sensitive or a check (or note) when throwing an error would be helpful?  such as 

    ValueError: invalid mode: 'W' -- your case appears to be an upper case, please ensure the case of the mode is correct


    ValueError: invalid mode: 'W' -- note the mode is case sensitive

could be helpful?

assignee: docs at python
components: Documentation
messages: 382322
nosy: docs at python, sean.grogan
priority: normal
severity: normal
status: open
title: case sensitivity in open() arguments
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list