[Tutor] Best way to convert a type into string

Gonçalo Rodrigues op73418@mail.telepac.pt
Fri Jan 10 07:33:02 2003


> >>> type(1)
> <type 'int'>
> 
> What's the best way to get the string "int" from this? My goal is to 
> construct a string similar to:
> 'pysqlite_pragma expected_types = int,str,int,float'
> by applying type() to a series of values.
> 
> repr(type(1))[7:-2] does it; I was hoping for something simpler.
>

Here is the simplest:

>>> print type(1).__name__
int
 
> Bob Gailer
> mailto:ramrom@earthling.net
> 303 442 2625
>

With my best regards,
G. Rodrigues