[Chicago] Python preprocessor

Ken Schutte kenschutte at gmail.com
Thu Oct 18 15:49:29 CEST 2012


Related to this previous thread about static analysis - is there any
kind of "hook" to do preprocessing of python file?  I recently wanted
to do this for something, so just made my own command,

$ mypython foo.py

mypython opened and read/modify/check the file, then just wrote a temp
file and call 'python' on that. Is there a better way?

This worked fine, but what I'd really want is something that would
also work for another script using "import foo".  I want the "foo"
being imported to be from the modified-on-the-fly file "foo.py".  I
could think of replacing "import foo" with something else which did
all kinds of complicated things, but can it be done so that the
importing file doesn't have to change?

Ken


More information about the Chicago mailing list