[Tutor] Re: FTP Question
Sheila King
sheila@thinkspot.net
Thu, 13 Jun 2002 19:17:22 -0700
On Thu, 13 Jun 2002 20:57:47 -0500, Derrick 'dman' Hudson wrote:
> | Since you did not assign any "identifier" or variable name to
> | reference the object, it will close as soon as you are done
> | working with it.
>
>
> This assumes that no dangling references exist. It also assumes
> there are no bugs in the interpreter that could crash it before
> that happens. I think it is better practice to assign it to a
> handle and explicitly close() it when you are done.
Personally, this is how I usually handle my file routines as well.
However, I was recently had someone review code I'd written, where I
did as you suggest (created a reference to the file, and then
specifically closed it), and when this much more experienced and
knowledgeable person reviewed my code, he wrote:
The following code:
f = open(HTML_template_file, 'r')
HTML_data = f.read()
f.close()
could just as easily be replace with:
f = open(HTML_template_file[, 'r']).read()
Matter of personal preference, I guess.
These comments were written by the author of the following software:
http://untroubled.org/
Now, your statements make good sense to me. <shrug>
--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org