Skip to main content
added 50 characters in body
Source Link
Martijn Pieters
  • 1.1m
  • 326
  • 4.2k
  • 3.4k

You have a dictionary, use the dict.get() method to return a default value for missing keys:

image_file = self.request.files.get('image_path') 

Also, do not use pokemon exception handling. You really don't need to catch them all here; if a key is missing, KeyError is raised, if you must use try..except should catch just that one exception with except KeyError:.

You have a dictionary, use the dict.get() method to return a default value for missing keys:

image_file = self.request.files.get('image_path') 

Also, do not use pokemon exception handling. You really don't need to catch them all here; if a key is missing, KeyError is raised, you should catch just that one exception.

You have a dictionary, use the dict.get() method to return a default value for missing keys:

image_file = self.request.files.get('image_path') 

Also, do not use pokemon exception handling. You really don't need to catch them all here; if a key is missing, KeyError is raised, if you must use try..except should catch just that one exception with except KeyError:.

added 181 characters in body
Source Link
Martijn Pieters
  • 1.1m
  • 326
  • 4.2k
  • 3.4k

You have a dictionary, use the dict.get()dict.get() method to return a default value for missing keys:

image_file = self.request.files.get('image_path') 

Also, do not use pokemon exception handling. You really don't need to catch them all here; if a key is missing, KeyError is raised, you should catch just that one exception.

You have a dictionary, use dict.get() to return a default value for missing keys:

image_file = self.request.files.get('image_path') 

You have a dictionary, use the dict.get() method to return a default value for missing keys:

image_file = self.request.files.get('image_path') 

Also, do not use pokemon exception handling. You really don't need to catch them all here; if a key is missing, KeyError is raised, you should catch just that one exception.

Source Link
Martijn Pieters
  • 1.1m
  • 326
  • 4.2k
  • 3.4k

You have a dictionary, use dict.get() to return a default value for missing keys:

image_file = self.request.files.get('image_path')