does python have useless destructors?
Mike at DeleteThis.Geary.com
Thu Jun 10 09:47:02 CEST 2004
> The correct idiom is:
> myfile = file("myfilepath", "w")
> I'd very much prefer something simpler that leaves no room
> for errors, e.g.
> with myfile = file("myfilepath", "w"):
> (this, and more generic solutions with code blocks have been
> suggested here many times)
That's just like the way you would code it in Ruby:
File.open( 'myfilepath', 'w' ) do |myfile|
myfile.write( reallybigbuffer )
More information about the Python-list