0

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

1
  • Actually I want to get a general way suitable for all the data types since there are also some other data types like blob and data. Commented Mar 11, 2014 at 1:49

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.