[Python-ideas] `to_file()` method for strings
Mark Lawrence
breamoreboy at yahoo.co.uk
Wed Mar 23 19:33:58 EDT 2016
On 23/03/2016 23:27, Sven R. Kunze wrote:
> On 23.03.2016 23:30, Alexander Belopolsky wrote:
>>
>> On Wed, Mar 23, 2016 at 6:20 PM, Sven R. Kunze <srkunze at mail.de
>> <mailto:srkunze at mail.de>> wrote:
>>
>> bash: echo "my string" >> my_file
>> python: with open('my_file', 'w') as f: f.write('my string')
>>
>> ...
>>
>> I can tell you from my experience with several aged Python
>> developers that they regularly fail to implement atomic file
>> operations. Just saying.
>>
>> What make you think your bash example implements an atomic write? It
>> actually performs an append and therefore not equivalent to the python
>> code that followed.
>
> What makes you think that I think my bash example implements an atomic
> write? ;-)
>
> My point was the simplicity of the bash command. Make it Python as
> simple AND atomic here (with file handling) and people will drop bash
> immediately.
>
>
In four decades I've never once felt the need for a one-liner that
writes a string to a file. How do you drop something that you've never
used and have no interest in?
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
More information about the Python-ideas
mailing list