Syntax error, "except pygame.error"
except, pygame, python, python-3.4
Solution
You have to use `as message` in python3 and `raise SystemExit(message)`:
def load_image(self, image_name):
try:
image = pygame.image.load(image_name)
except pygame.error as message:
print("Cannot load image: " + image_name)
raise SystemExit(message)
return image.convert_alpha()
Also `print` is a `function` in `python3` so you need parens.
Problem
I am a python and pygame noob, looked up a tutorial for loading sprites in to my game, and I'm getting syntax error for this this line of code ``` except pygame.error, message: ^ SyntaxError: invalid syntax ``` This is the entire block of code: ``` def load_image(self, image_name): try: image = pygame.image.load(image_name) except pygame.error, message: print "Cannot load image: " + image_name raise SystemExit, message return image.convert_alpha() ``` I didn't check if the tutorial was for python 3.4.2 or not, has the syntax changed? Or is there something else wrong with my code?