type(x) syntax in a test

Richard Brodie R.Brodie at rl.ac.uk
Wed Aug 23 06:11:46 EDT 2000


"Bellamy Bruno" <bellamy at freesurf.fr> wrote in message
news:967024838.2137696526 at news.club-internet.fr...

> I guess my mistake is a typical beginner's one, sorry...
> But I just can't find the right syntax to make a test on a type.

type(x) returns a type object. See the documentation for the
types module for details.

Alternatively use: if type(a) == type('string') [or type('banana')]







More information about the Python-list mailing list