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. :-)

tags:
posted in Uncategorized by admin

Follow comments via the RSS Feed | Leave a comment | Trackback URL

Leave Your Comment

You must be logged in to post a comment.

 
Powered by Wordpress and MySQL. Theme by openark.org