Determining Types

Chris Dutton chris at cmb-enterprises.com
Sat Sep 1 14:35:21 EDT 2001


in article fe9k7.1835$ix.446807 at newsrump.sjc.telocity.net, Adonis Vargas at
deltapigz at telocity.com wrote on 9/1/01 1:51 PM:

> how am i able to determine types of variables? i have come up with the
> type() function but am unsuccessful in using it. this is the code in which
> im using the provided function:
> 
> def convert():
> if type(txth1.get()) == 'int':
> print 'its an int'
> elif type(txth1.get()) == 'str':
> print 'its a string'

you might want to try...

def convert():
    if type(txth1.get()) == type(1):
        print 'its an int'
    elif type(txth1.get()) == type("a"):
        print 'its a string'




More information about the Python-list mailing list