import ast, sys for p in ['/home/hmo/MoFin/deploy/profile-scripts/batch_reassess.py', '/home/hmo/MoFin/deploy/profile-scripts/premarket_full_review.py']: try: ast.parse(open(p).read()) print('OK:', p) except SyntaxError as e: print('SYNTAX ERROR:', p, e) sys.exit(1)