if itemCode is not None:
    print('code missing')
dbObject = db.GqlQuery('SELECT * FROM %s WHERE code=:1' % dbName, itemCode
    ).get()
dbObject.delete()
How to use try, except, else correctly in Python