0

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.

user1357159
  • 309
  • 5
  • 19

1 Answers1

1

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.

msw
  • 42,753
  • 9
  • 87
  • 112
  • Do you think it would be possible to do this with pyFlakes or pyLint, I was looking at the code for both and they are pretty complicated – user1357159 Jun 09 '12 at 16:23