Why no open(f, "w").write()?
Sean 'Shaleh' Perry
shalehperry at attbi.com
Wed May 29 16:05:34 EDT 2002
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.
More information about the Python-list
mailing list