code: def is_binary(var, allow_none=False):
      
      return isinstance(var, six.binary_type) or (var is None and allow_none)
docs: Returns True if var is a binary (bytes) objects
  
          Result             py-2  py-3
          -----------------  ----- -----
          b'bytes literal'   True  True
           'string literal'  True  False
          u'unicode literal' False False
  
          Also works with the corresponding numpy types.