Mercurial > genshi > mirror
changeset 1022:500573200533 trunk
Add isstring helper.
author | hodgestar |
---|---|
date | Sun, 16 Feb 2014 18:43:20 +0000 |
parents | 323d592690da |
children | 2036193f89e7 |
files | genshi/compat.py |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/genshi/compat.py +++ b/genshi/compat.py @@ -35,6 +35,15 @@ 'Python 2 compatibility function. Not usable in Python 3.') +# We need to test if an object is an instance of a string type in places + +if IS_PYTHON2: + def isstring(obj): + return isinstance(obj, basestring) +else: + def isstring(obj): + return isinstance(obj, str) + # We need to differentiate between StringIO and BytesIO in places if IS_PYTHON2: @@ -112,4 +121,3 @@ if not x: return False return True -