user3534160
user3534160

Reputation: 21

InvalidSyntax on Python IF statement

I can't figure out what's wrong below... keep getting syntax error on the IF statement.

#Specify a key file
keyfile="C:\Python27/keepasskey"

try:
 debug = Debug()

if os.path.isfile(keyfile):
 print "[+] Keyfile Loaded: '" + keyfile + "'"
 aProcess = debug.execv(['KeePass.exe', 'Database.kdb', '-keyfile:' + keyfile, '-pw:'.ljust(WORD_SIZE+4)])
else:
    print "[+] Specified keyfile '" + keyfile + "' does not exist, ignoring argument"
    aProcess = debug.execv( ['KeePass.exe', 'Database.kdb', '-pw:'.ljust(WORD_SIZE+4)])

Thanks in advance!

Upvotes: 1

Views: 69

Answers (1)

wheaties
wheaties

Reputation: 35980

You need to indent your if statement so that it's probably within the scope of the try statement or else you need to put in a except after the try but before the if. Like so:

try:
  debug = Debug()
  if os.path.isfile(keyfile):
    print "Indentation is required and part of the language syntax"

Upvotes: 2

Related Questions