Re: compiling module from string and put into namespace

2006-05-13 Thread Fuzzyman
glomde wrote: > Ok, now I think I know what I need to do. > I need to create a variable in the calling functions locals. > So how do I get access to the calles locals dictionary? > Is it possible? If your import is used in the current namespace, just use the global keyword. Best is if your funct

Re: compiling module from string and put into namespace

2006-05-13 Thread Edward Elliott
glomde wrote: > I didnt mean that __import__ isnt a function, but that I want to > make a function called ImoprtFile that actually does something > very similar that what __import__. > > So to rephrsase the questin how does __import__ load a module > into the callers namespace. Ok got it now.

Re: compiling module from string and put into namespace

2006-05-13 Thread glomde
Ok, now I think I know what I need to do. I need to create a variable in the calling functions locals. So how do I get access to the calles locals dictionary? Is it possible? -- http://mail.python.org/mailman/listinfo/python-list

Re: compiling module from string and put into namespace

2006-05-13 Thread glomde
> I dont want the caller to call import but a function. come again? >>> type (__builtins__.__import__) I didnt mean that __import__ isnt a function, but that I want to make a function called ImoprtFile that actually does something very similar that what __import__. So to rephrsase the questi

Re: compiling module from string and put into namespace

2006-05-13 Thread Bruno Desthuilliers
glomde a écrit : > Tanks but that isn't what I am looking for. > I really want a function that you can call and imports > the module into the calling functions namespace. Please read the documentation of the __import__() *function*. (notice the double leading and ending underscores and the parent

Re: compiling module from string and put into namespace

2006-05-12 Thread Edward Elliott
glomde wrote: > Tanks but that isn't what I am looking for. > I really want a function that you can call and imports > the module into the calling functions namespace. > > I dont want the caller to call import but a function. come again? >>> type (__builtins__.__import__) -- Edward Elliott

Re: compiling module from string and put into namespace

2006-05-12 Thread glomde
Tanks but that isn't what I am looking for. I really want a function that you can call and imports the module into the calling functions namespace. I dont want the caller to call import but a function. -- http://mail.python.org/mailman/listinfo/python-list

Re: compiling module from string and put into namespace

2006-05-12 Thread bruno at modulix
glomde wrote: > Hi, > > I want to create a function that preprocesses a file and then imports > the parsed file. > > What I found out is that you can do something like this: > > def ImportFile(fileName): > parsedCode = Parser(fileName).Parse() > module = new.module(name) > exec parse