[DB-SIG] dbiDateType = type(dbi.dbiDate(0))
Magnus Lyckå
magnus at thinkware.se
Tue Jun 3 10:42:36 EDT 2003
At 19:00 2003-06-02 -0400, Jeff wrote:
>>for item in my_list:
>> if type(item) is StringType:
>> print 'Foo'
>> elif type(item) is DbiDate:
>> print 'Bar'
>> else:
>> print 'Baz'
>>
>>But DbiDate is an object, not a type.
Everything is an object... As you already showed, the object
in question is not of instance type, but of DbiDate type.
( <type 'DbiDate'> )
>>I thought is instance might be the ticket, since it can compare classes
>>_and_ types. No luck so far. Apparently I am the first person in the
>>history of DBI to want to do this.
No, it's quite simple. You need to get a type object! It's probably
directly available somewhere, but why search for that when you can
make one---type() returns type objects!
dbiDateType = type(dbi.dbiDate(0))
if type(item) == dbiDateType:
...
It seems you are using the old ODBC interface in win32all.
It's not really supported as far as I understand, and not
complient with DB-API 2. mxODBC or adodbapi might be a
better choice.
--
Magnus Lycka (It's really Lyckå), magnus at thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The shortest path from thought to working program
More information about the DB-SIG
mailing list