Michael B. Trausch wrote: > Not really über-qualified to say anything, but I think that the > following would be better: > > try: > f = open('file.sql') > script = f.read() > f.close() > except IOError: > wx.MessageBox('Message', 'Message Title') > >> Do they both do the same thing? >> > > Not sure about the with-- I just went to read the PEP on it, and it > confused me greatly. :-) So, I don't know. >
when .read() fails the file will not be close here. to replace the 'with' solution you#d need: try: f=open(path) try: script=f.read() finally: f.close() except EnvironmentError,v: wx.MessageBox(v, 'Message Title') -robert -- http://mail.python.org/mailman/listinfo/python-list