Thursday 15 August 2013

Python type equality -


I am reading from an Oracle database and would like to check whether the field is column type cx_Oracle.DATETIME .

I have tried the following:

If the column type [columnIndex] == cx_Oracle.DATETIME:

If the column type is [columnIndex] cx_Oracle.DATETIME:

Neither work.

If I do:

Print column type [columnIndex]

gives it:

& lt; Type 'cx_Oracle.DATETIME' & gt; Edit If the column type [columnIndex] == dbDateType

The best way is possible:

  isinstance (column type [column index], cx_Oracle.DATETIME)   

If you want to check the exact type, type (obj) == myType woudl work, then using isinstance sub-typing Allows for

No comments:

Post a Comment