I'm converting a mimeData object to a human-readable string when it gets dropped onto another widget. That's all working fine, with the exception of a slight spacing issue.
Here's the code:
import re
event.accept()
format = "application/x-qabstractitemmodeldatalist"
data = event.mimeData().data(format)
pattern = re.compile('\W')
item = re.sub(pattern, '', str(data))
print str(data) # prints smiley face, other unicode characters, then J o h n n y D e p p
print item # prints JohnnyDepp
How can I get Johnny Depp
out of the mimeData instead of JohnnyDepp
or J o h n n y D e p p
?