include in python
Tyler Eaves
tyler at cg1.org
Mon May 5 07:01:48 EDT 2003
Bartek Golenko wrote:
> Bartek Golenko <bartek at debian.caton.com.pl> wrote:
>> rewritten anyway, but right now I just want a convinient way to split
>> the source code into smaller chunks.
>
> Well, silly to ansver my own question but here is a little workaround I
> just found:
>
> fname="primitives.py"; f=open(fname, "r");
> c=compile(f.read(), fname, "exec"); eval (c)
>
> fname="xmlhelper.py"; f=open(fname, "r");
> c=compile(f.read(), fname, "exec"); eval (c)
>
> It seems to work just fine.
>
> It could possibly be converted into a nice
> def include(fname):
> ...
> eval (c, with_sth_wise_here..)
>
> but I have no idea how to reference globals dictionary
>
Or you could just do execfile('filename')
More information about the Python-list
mailing list