def convert(data):
try:<EOL><INDENT>st = basestring<EOL><DEDENT>except NameError:<EOL><INDENT>st = str<EOL><DEDENT>if isinstance(data, st):<EOL><INDENT>return str(data)<EOL><DEDENT>elif isinstance(data, Mapping):<EOL><INDENT>return dict(map(convert, data.iteritems()))<EOL><DEDENT>elif isinstance(data, Iterable):<EOL><INDENT>return type(data)(map(convert, data))<EOL><DEDENT>else:<EOL><INDENT>return data<EOL><DEDENT>
Convert from unicode to native ascii