0

When I read Exception Handling Sample Code about cx_Oracle module, I can't understand some of the codes. The code is "error_obj, = e.args". What is means "Variable, ="

Sampel Code:

try:
    cursor.execute("insert into customer values (101, 'Customer A')")
except cx_Oracle.IntegrityError as e:
    error_obj, = e.args
    print("Customer ID already exists")
    print("Error Code:", error_obj.code)
    print("Error Message:", error_obj.message)
else:
    print("Customer added")

Link: https://cx-oracle.readthedocs.io/en/latest/user_guide/exception_handling.html

Guy
  • 46,488
  • 10
  • 44
  • 88
  • https://docs.python.org/3/reference/expressions.html?highlight=assignment. Be aware that you can assign multiple values at once, you can also assign from a tuple to multiple values and vice versa. – Ulrich Eckhardt Aug 10 '21 at 05:54
  • This is mentioned in the Python primer of the cx_Oracle tutorial: https://oracle.github.io/python-cx_Oracle/samples/tutorial/Python-and-Oracle-Database-Scripting-for-the-Future.html#primer – Christopher Jones Aug 10 '21 at 23:11

0 Answers0