Why no open(f, "w").write()?
Huaiyu Zhu
huaiyu at gauss.almadan.ibm.com
Wed May 29 17:02:21 EDT 2002
Sean 'Shaleh' Perry <shalehperry at attbi.com> wrote:
>
>On 29-May-2002 Michael P. Soulier wrote:
>> On 24 May 2002 07:53:38 GMT, Markus Demleitner
>> <msdemlei at tucana.cl.uni-heidelberg.de> wrote:
>>>
>>> The Jython docs state that
>>> open("some.name", "w").write(stuff)
>>> is bad programming practice (and indeed claim that in Jython,
>>> the above construct leaves some.name empty).
>>
>> I can't speak for Jython, but in CPython 2.1, it works fine.
>>
>>>>> stuff = "stuff to write"
>>>>> open('stufffile', "w").write(stuff)
>>>>> open('stufffile', "r").read()
>> 'stuff to write'
>>
>
>yes, but can you disagree with the statement that it is bad programming
>practice. I sure can't.
For what reason is it bad?
Huaiyu
More information about the Python-list
mailing list