Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Test if an argument is an integer

Tags:

I want to write a python script that takes 3 parameters. The first parameter is a string, the second is an integer, and the third is also an integer.

I want to put conditional checks at the start to ensure that the proper number of arguments are provided, and they are the right type before proceeding.

I know we can use sys.argv to get the argument list, but I don't know how to test that a parameter is an integer before assigning it to my local variable for use.

Any help would be greatly appreciated.