try...else...except syntax error
        Posted  
        
            by iform
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by iform
        
        
        
        Published on 2010-05-08T00:52:00Z
        Indexed on 
            2010/05/08
            0:58 UTC
        
        
        Read the original article
        Hit count: 394
        
python
I can't understand this...
Cannot get this code to run and I've no idea why it is a syntax error.
    try:
        newT.read()
        #existingArtist = newT['Exif.Image.Artist'].value
        #existingKeywords = newT['Xmp.dc.subject'].value
    except KeyError:
        print "KeyError"
    else:
        #Program will NOT remove existing values
        newT.read()
        if existingArtist != "" :
            newT['Exif.Image.Artist'] = artistString
        print existingKeywords
        keywords = os.path.normpath(relativePath).split(os.sep)
        print keywords
        newT['Xmp.dc.subject'] = existingKeywords + keywords
        newT.write()
    except:
        print "Cannot write tags to ",filePath
Syntax error occurs on the last "except:". Again...I have no idea why python is throwing a syntax error (spent ~3hrs on this problem).
© Stack Overflow or respective owner