correct way to catch exception with Python 'with' statement
Ganesh Pal
ganesh1pal at gmail.com
Mon Nov 28 10:18:01 EST 2016
On Mon, Nov 28, 2016 at 1:16 PM, Steven D'Aprano <
steve+comp.lang.python at pearwood.info> wrote:
>
>
> There is no need to return True. The function either succeeds, or it
> raises an
> exception, so there is no need to return any value at all.
>
>
I returned True here ,because based on the result of this function , I
would want to perform next steps
Example
if create_files_append():
do_somthing()
else:
do_next_thing()
>
> Your comment says "append the files", but you're not appending to the
> files,
> you are overwriting them. So your code is better written like this:
>
>
Yes , correct and apologies there was a typo it should have been 'a'
instead of 'w' . Thanks for the comments
More information about the Python-list
mailing list