[Python-ideas] Add create mode to open()

Guido van Rossum guido at python.org
Wed Aug 17 03:14:28 CEST 2011


On Tue, Aug 16, 2011 at 5:58 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
> Guido van Rossum <guido at python.org> writes:
>
>> So what's the use case?
>
> I agree that I don't see the use case that isn't already adequately
> covered. You generally get what you explicitly ask for, and that's how
> it should be.
>
> A point of correction, though:
>
>> In general when using a command line environment overwriting the file
>> is what you *want* to happen. Like with Unix "foo >bar". I don't even
>> think there *is* a shell syntax for not overwriting an existing file,
>
> The ‘bash(1)’ man page describes the ‘noclobber’ option:
>
>    If the redirection operator is >, and the noclobber option to the
>    set builtin has been enabled, the redirection will fail if the file
>    whose name results from the expansion of word exists and is a
>    regular file.

Thanks, I'd forgotten that. It seems wrong that it is a global flag though.

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list