[Tutor] do I need f.close()
bob gailer
bgailer at gmail.com
Tue Jun 10 19:54:49 CEST 2008
dave selby wrote:
> Hi All,
>
> Up to now I when I need to write some data to a file I have been
> purposely using close()
>
> f = open(conf, 'w')
> f.writelines(lines)
> f.close()
>
> Is it as safe to use the following ....
>
> open(conf, 'w').writelines(lines)
>
> ie no close() to flush the data, but also not assigned an object name
> so am I right in thinking that as the object is 'reclaimed' close() is
> automatically called ?
>
True. And not, imho, "bad programming"
--
Bob Gailer
919-636-4239 Chapel Hill, NC
More information about the Tutor
mailing list