Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sympy
#2
You cannot catch SyntaxError, since it is raised prior code execution (i.e. before try and except are executed); If you use eval, you can be able to catch it, e.g.

from sympy.abc import x, y
code = """
   e = x + y + x)
"""
try:
   eval(code)
except SyntaxError:
   print("Hello")
Reply


Messages In This Thread
sympy - by psosmol - Mar-09-2019, 11:16 AM
RE: sympy - by scidam - Mar-09-2019, 11:30 AM
RE: sympy - by psosmol - Mar-09-2019, 03:55 PM
RE: sympy - by stullis - Mar-09-2019, 05:33 PM
RE: sympy - by psosmol - Mar-09-2019, 06:05 PM
RE: sympy - by scidam - Mar-10-2019, 06:20 AM
RE: sympy - by psosmol - Mar-10-2019, 08:35 AM
RE: sympy - by scidam - Mar-11-2019, 12:00 AM
RE: sympy - by psosmol - Mar-11-2019, 10:23 AM
RE: sympy - by scidam - Mar-11-2019, 11:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python sympy problem for symbolic equation definition joellapointe_engineering 0 301 Mar-24-2024, 11:09 PM
Last Post: joellapointe_engineering
  Sympy nonlinsolve does not return explicit solution axelle 1 2,302 Jan-20-2021, 11:38 AM
Last Post: Serafim
  plot differential equation sympy dan_adi 0 3,040 Oct-13-2020, 10:44 AM
Last Post: dan_adi
  Attribute error - Sympy VictorG8 1 5,069 Apr-09-2020, 06:03 PM
Last Post: snippsat
  How to use list of symbols for sympy calculation in python? tanmaybhise 1 2,847 Mar-01-2020, 10:36 PM
Last Post: Gribouillis
  Next zero of a function on sympy VicenteM 0 2,117 Aug-21-2019, 04:58 PM
Last Post: VicenteM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020