I'm trying to create an exception based on whether or not a file has been removed:
def remove_file():
print("Removing the output file: ", output_file)
try:
os.remove(output_file)
except RemoveFileError,e:
remove_stat = e.returncode
if remove_stat == 0:
print("File Removed!")
But I'm getting the following error:
File ".\aws_ec2_list_instances.py", line 198
except RemoveFileError,e:
^
SyntaxError: invalid syntax
I thought I could call the exception whatever I wanted. Is that not the case? How can I write this correctly?
except RemoveFileError as e: