Robert Kern wrote:

>> I usually use:
>> 
>> try:
>>   f = open(file)
>>   contents = f.read()
>> finally:
>>   f.close()
>> 
>> But now I am wondering if that is the same thing. Which method would
>> you rather use? Why?
> 
> Just keep doing what you are doing, please.

Note quite.  The assignment of the resources to its variable needs to be 
done before the try:

        f = open(file)
        try:
            contents = f.read()
        finally:
            f.close()

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Who, my friend, can scale heaven?
   -- _Gilgamesh_, ca. 3rd C. BC
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to