You can use `isinstance(d['radio'], basestring)` here to capture both.