Pregunta

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.

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top