Is it defined behaviour that all files get implicitly closed when not
assigning them?

Like:

def writeFile(fName, foo):
        open(fName, 'w').write(process(foo))

compared to:


def writeFile(fName, foo):
        fileobj = open(fName, 'w')
        fileobj.write(process(foo))
        fileobj.close()

Which one is the 'official' recommended way?

Thomas
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to