New submission from Sean Grogan <[email protected]>:
I was stuck on a problem today using an open statement where I was trying to
open a file for writing
e.g.
with open("RESULTS.CSV", "W") as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerow(["X", "Y"])
csvwriter.writerows(data)
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
or
ValueError: invalid mode: 'W' -- note the mode is case sensitive
could be helpful?
----------
assignee: docs@python
components: Documentation
messages: 382322
nosy: docs@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 <[email protected]>
<https://bugs.python.org/issue42543>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com