In article <11**********************@i40g2000cwc.googlegroups .com>,

"Eli" <el*****@gmail.com> wrote:

Hi,

I want to check whether a value is a scalar. A scalar can be:

- None (null)

- string

- number (integer, float)

- boolean

How can I validate a value is one of these types?

I care about the value only, and not its class methods.

An object is not a scalar, since it's not a simple value.

An array might be considered as scalar.

The issue is I want to keep a set of values to share among several

applications in different languages, and only scalar values can be

shared. Since objects are not the same in all languages, it's possible

to share only simple values.

-thanks

I'm not sure what "scalar" means in this context. You say "an object is

not a scalar", but you also assert that an integer is a scalar. These are

contradictory statements, since integers *are* objects:

isinstance (1, object)

True

You say that numbers are scalars. All nunmbers, or just integers and

floats? What about complex numbers? What about long integers?

In any case, the way to check for a type is with isinstance(), as I did

above).