Python implementation of "include"

Tim Couper tim.couper at scivisum.co.uk
Thu Dec 13 16:21:27 EST 2007


import myFile

would achieve this

TIm

lloyd at paisite.com wrote:
> Hello,
>
> I've been using the Python-based Karrigell web application framework. 
> It has the very handy word "include" that inserts a code file into 
> into the stream of execution. E.g. if myFile.py contains the code:
>
> print "This is a message from myFile.py<br>"
>
> and my script is:
>
> print "Something<br>"
> include "myFile.py"
> print "Something more<br>"
>
> The output would be:
>
> Something
> This is a message from myFile.py
> Something more
>
> Since I'm considering moving my application to a different web 
> application framework, I'd like to replace include with a pure python 
> construct. I've discovered several ways to do it, but they all seem 
> kludgy in one way or another. Is there a simple, elegant way to do this?
>
> Many thanks,
>
> Lloyd
>
>
>
>
>
>



More information about the Python-list mailing list