• Feb
    20
    2009

    Reading an arbitrary file as python module source

    Not sure if anybody will ever need this. I just found out because I did not accept that I can’t load my Subversion pre-commit hook as a module.
    Of course it is actually quite simple:

    import imp
    hook = imp.load_source(“hook”, “pre-commit”)

    It’s that easy. Now I can test the internal functions from ipython before letting it wreck our repository. [...]

 
Powered by Wordpress and MySQL. Theme by openark.org