[DB-SIG] dbiDate - help urgently needed
Lloyd Kvam
pythontutor at venix.com
Mon Jun 2 19:59:09 EDT 2003
dbiDate is form the old 1.0 API
http://www.python.org/topics/database/DatabaseAPI-2.0.html
Python Database API v2.0
It specifies using mx.DateTime for date time values.
The Python language just recently evolved to unify tpyes and classes.
>>> isinstance(1, int)
1
>>> import mx.DateTime as DT
>>> d = DT.Date(2003,6,2)
>>> d
<DateTime object for '2003-06-02 00:00:00.00' at 13dd310>
>>> isinstance(d, DT.DateTime)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: isinstance() arg 2 must be a class or type
>>> isinstance(d, DT.DateTimeType)
1
Not all of the modules support isinstance in the way you would expect. So
we will probably be using type(obj_reference) for a while longer.
Jeff Sacksteder wrote:
>> Do print `type(known_dbiDate_object)`, and that will print enough
>> information to figure out what type it actually is. If you're having
>> difficulty with type and isinstance, then there's a good chance you're
>> not really looking at dbiDate objects.
>
>
>
> for item in my_list:
> print type(item)
>
> returns the following-
>
> <type 'float'>
> <type 'string'>
> <type 'DbiDate'>
>
> I want to do something like-
>
> 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. 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.
>
>
> _______________________________________________
> DB-SIG maillist - DB-SIG at python.org
> http://mail.python.org/mailman/listinfo/db-sig
>
--
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358
voice: 603-443-6155
fax: 801-459-9582
More information about the DB-SIG
mailing list