Type testing

William Park parkw at better.net
Wed Mar 15 12:13:24 EST 2000


On Wed, Mar 15, 2000 at 06:01:23PM +0100, Alessandro Bottoni wrote:
> Is it possible to test for the type of an object (I mean, a built-in object:
> a digit, a string, etc...)?
> 
> I'm looking for something like:
> 
> Result = isDigit(MyVariable)
> 
> Result = isString(MyVariable)
> 
> (Result = true | false, 1 | 0)
> 
> Thanks.

Use standard module 'types',
    import types
or do manually like,
    type(MyVariable) == type('')




More information about the Python-list mailing list