Re: question about try/except blocks

2013-05-02 Thread Steven D'Aprano
On Thu, 02 May 2013 21:54:29 -0400, J wrote: > I have this function in a class: > > def write_file(self, data, dest): > with open(dest, 'wb', 0) as outfile: > try: > print("IN WRITE_FILE") > outfile.write(self.data) > except IOError

Re: question about try/except blocks

2013-05-02 Thread Devin Jeanpierre
On Thu, May 2, 2013 at 9:54 PM, J wrote: > Would it be better to wrap the call and catch the OSError there, or > wrap the whole with open() block in the function itself? > > My thought is to wrap the with open() call in the function so that I'm > not wrapping the function call every time I use the