[Tutor] Quick way to find the data type

Kent Johnson kent37 at tds.net
Tue Sep 27 21:27:44 CEST 2005


Bernard Lebel wrote:
> Hello,
> 
> Let say I have a string. The value of the string might be 'False',
> 'True', '3', '1.394', or whatever else. Is there a quick way to
> convert this string into the appropriate data type other than with
> try/except?

There is a nice solution here:
http://groups.google.com/group/comp.lang.python/msg/5ead7dae977ed990?hl=en&

It doesn't avoid the try/except but it wraps it up real pretty :-)

Kent



More information about the Tutor mailing list