I need to do one thing if args is integer and ather thing if args is string.
How can i chack type? Example:
def handle(self, *args, **options):
if not args:
do_something()
elif args is integer:
do_some_ather_thing:
elif args is string:
do_totally_different_thing()
First of,
*argsis always a list. You want to check if its content are strings?It uses
types.StringTypesbecause Python actually has two kinds of strings: unicode and bytestrings – this way both work.In Python3 the builtin types have been removed from the
typeslib and there is only one string type.This means that the type checks look like
isinstance(s, int)andisinstance(s, str).