I have some code that pulls data from a com-port and I want to make sure that what I got really is a printable string (i.e. ASCII, maybe UTF-8) before printing it. Is there a function for doing this? The first half dozon places I looked didn't have anything that looks like what I want. (string has printable but I didn't see anything (there or in the string methods) to check if every char in one string is in another.
Note: control characters are not printable for my purposes.
Edit: I was/am looking for a single function, not a roll your own solution:
What I ended up with is:
all(ord(c) < 127 and c in string.printable for c in input_str)