help, function to get variable type

I

iip

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...

thanks,

-iip-
 
H

Hong Jiang

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...

x=type(m)

x will be str, int, tuple, dict ... etc.
 
A

Alex Martelli

iip said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,173
Messages
2,570,937
Members
47,481
Latest member
ElviraDoug

Latest Threads

Top