I'm not good at Python, and I'm trying to make this script work, and it fails at an 'except statement'. Here is the block of code, it's part of a larger script:
    try:  # to read the keyfile
        with open(args.keyfile, 'r') as fp:
            tmp_dict = json.load(fp)
        fp.close()
        except IOError:
            tmp_dict = {self.name: {}}
        if self.name not in tmp_dict.keys():
            tmp_dict[self.name] = {}
    # The xauth token should not be stored in clear text. encode()
    # will use the Vigenere cipher to encrypt it, using the password as
    # a key.
    tmp_dict[self.name]['xauth'] = encode(args.password, self.xauth)
    tmp_dict[self.name]['url'] = self.url
    tmp_dict[self.name]['urlbase'] = self.urlbase
    tmp_dict[self.name]['urlspan'] = self.urlspan
    tmp_dict[self.name]['last_access_time'] = self.last_access_time
This the error I'm geting:
  File "./zfs_session.py", line 37
except IOError:
     ^
SyntaxError: invalid syntax
Thanks
 
    