Do not use
isinstance(s, basestring) as basestring has been removed in
Python3. You can import
ansible.module_utils.six and then use
isinstance(s, (binary_type, text_type)) instead.
If this is part of code to convert a string to a particular type,
ansible.module_utils._text contains several functions that may be even
better for you: