where to find win32 com <type 'time'>

Mark Hammond mhammond at skippinet.com.au
Wed Jan 8 18:20:43 EST 2003


news.sandia.gov wrote:
> I'm using the win32com extensions for Python to query a database with 
> time columns in it.  When I get a result, I want to be able to identify 
> if the type of the value is (specifically if it's a 'time' type).  
> Currently, I'm using the string returned by the representation of the 
> type, but I'd rather use the object itself if possible.
>  
> # example
> import win32com.client
> conn = win32com.client.Dispatch( 'ADODB.Connection' )
> conn.Open( <ODBCNAME> )
> rst, res = conn.Execute( <QUERY> )
> values = rst.GetRows( -1, 0, 0 )[0] # get the first column as a sequence
> for value in values:
>   if repr( type( value ) ) == "<type 'time'>":
>     pass # do something with the time value
>  
> My motivation for doing this is I have a generic class that is 
> responsible for manipulating the data regardless of type, but at some 
> point it has to know the type to properly manituplate it.  I don't know 
> how to refer to the <type 'time'> object, however to compare it with the 
> type( value ).

 >>> pywintypes.TimeType
<type 'time'>

Mark.





More information about the Python-list mailing list