>>>>> "ET" == ed tsang <ed_tsang at yahoo.com> writes: ET> Hi My current script, say script A, need to execute some python ET> code in other file, say script B, by using exec() function. But ET> if there is any syntax error in script B, the exec() returns, ET> but I would not know what kind of syntax error is that. I'm afraid I don't understand what problem you are having. If you use the exec statement or the builtin compile function to compile Python source code and the source code contains a SyntaxError, the exec/compile will raise a SyntaxError. >>> exec "() += 1" Traceback (most recent call last): File "<stdin>", line 1, in ? File "<string>", line 1 SyntaxError: can't assign to () >>> compile("[x for x in x] = x", "<string>", "exec") Traceback (most recent call last): File "<stdin>", line 1, in ? File "<string>", line 1 SyntaxError: can't assign to list comprehension >>> try: ... exec "() += 1" ... except SyntaxError, err: ... pass ... else: ... err = None ... >>> err <exceptions.SyntaxError instance at 0x80d82cc> Is your application generates a SyntaxError? If it is, what do you want to happen? Jeremy
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4