help, function to get variable type
Alex Martelli
aleax at aleax.it
Thu Dec 25 12:14:03 EST 2003
iip wrote:
> Hi All,
>
> What is the function to check the varible type, for example, below is like
> in my clipper language:
>
> x = valtype(m)
>
> x will be "N", "C", "A", etc...
type(x) will return the type object itself (not a string representing
it, but really the type object). If you need to map type objects to
strings, there are several ways to do that, of course (e.g., each type
object has an attribute __name__ which is just the kind of string one
would expect -- 'int', 'str', and so on -- so type(x).__name__ may be
a first approximation to the kind of string you're looking for).
Alex
More information about the Python-list
mailing list