Testing Whether an Object is String-like

A simple and fast way to check whether something is a string or Unicode object is to use the built-ins isinstance and basestring, as follows

def isString(anObj):
         return isinstance(anObj,basestring)
Share

Leave a Reply

Your email address will not be published. Required fields are marked *