(Edited 02/07/2013 03:59 PM) | Report

Python - test if variable is a string

In Python 2.x - string can be str or unicode, so the test is:

isinstance(s, basestring)

In Python 3.x - there are only unicode strings (str):

isinstance(s, str)
Topics: Other

Replies

 Anonym
No regstration needed to add reply
Insert: Picture