Flatten the module to a string and check if it starts with '
import matplotlib
foobarbaz = "some string"
print(str(matplotlib).startswith("
Drawback being this could collide with a python string that starts with the text ' You could try to classify it more strongly with a regex.