我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用__builtin__.basestring()。
def _flags_to_int(flags): # Note, that order does not matter, libev has its own predefined order if not flags: return 0 if isinstance(flags, integer_types): return flags result = 0 try: if isinstance(flags, basestring): flags = flags.split(',') for value in flags: value = value.strip().lower() if value: result |= _flags_str2int[value] except KeyError as ex: raise ValueError('Invalid backend or flag: %s\nPossible values: %s' % (ex, ', '.join(sorted(_flags_str2int.keys())))) return result
def inline(f, *args, **kwds): if isinstance(f, basestring): global _cython_inline if _cython_inline is None: from Cython.Build.Inline import cython_inline as _cython_inline return _cython_inline(f, *args, **kwds) else: assert len(args) == len(kwds) == 0 return f