Question

I am trying to get pyChecker to check the syntax of a string.

s="""
print "hi"
print "hello"
print 3/0
"""

Is there anyway I can do this, I was trying to change the source code of pyChecker to read a string but it is too confusing. I could be missing a built in way to do this.

Was it helpful?

Solution

From the documentation:

PyChecker works in a combination of ways. First, it imports each module. If there is an import error, the module cannot be processed.

Since import does quite a bit of work under the covers, including a full compilation pass that PyChecker needs to do its tricks, my guess is that you'd do far, far better writing s to a file. The alternative would reinvent some complicated wheels.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top