Save to a file, but avoid overwriting an existing file
Ben Finney
ben+python at benfinney.id.au
Wed Mar 12 20:22:55 EDT 2014
Cameron Simpson <cs at zip.com.au> writes:
> Therefore you need to continue _only_ if you get EEXIST. Otherwise
> abort.
If you target Python 3.3 or later, you can catch “FileExistsError”
<URL:http://docs.python.org/3/library/exceptions.html#FileExistsError>
which is far simpler than messing around with ‘errno’ values.
--
\ “I know you believe you understood what you think I said, but I |
`\ am not sure you realize that what you heard is not what I |
_o__) meant.” —Robert J. McCloskey |
Ben Finney
More information about the Python-list
mailing list