use isinstance of 'str', not 'basestring'