Вопрос

For example, if I have following code:

#people( sin, name, height,weight,eyecolor, haircolor,addr,gender,birthday )
sin = input("sin ---->")  
gender = input("gender ---->")

I need check whether 'sin' is an integer or say, a 'INT' in oracle data type.

And whether gender is f or m.

How can I do this? Is there any different way from:

while gender != 'f' or gender != 'm':
    gender = input("gender ---->")

The two attributes above will be insert into my database by SQL statement

I am using cx_Oracle

Это было полезно?

Решение

Can you use isinstance()?

isinstance(sin, int) will eval to true or false. isinstance(object_instance, object_type) might work for the other objects you want to evaluate as well.

Your checking of 'f' or 'm' is a bit different since you're comparing data rather than type. Not sure if you can get around that way of checking data.

Hope that helps.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top