Re: Function to import module to namespace

2008-06-30 Thread bvdp
John Machin wrote: On Jun 30, 11:45 am, bvdp <[EMAIL PROTECTED]> wrote: John Machin wrote: Good questions. Short answer ... probably 'cause I've not thought the problem though completely :) > You are updating with *everything* in the 'more' module, not just the > functions. This includes s

Re: Function to import module to namespace

2008-06-30 Thread John Machin
On Jun 30, 11:45 am, bvdp <[EMAIL PROTECTED]> wrote: > John Machin wrote: > > > > Good questions. Short answer ... probably 'cause I've not thought the > problem though completely :) > > > You are updating with *everything* in the 'more' module, not just the > > functions. This includes such thi

Re: Function to import module to namespace

2008-06-29 Thread bvdp
John Machin wrote: Good questions. Short answer ... probably 'cause I've not thought the problem though completely :) > You are updating with *everything* in the 'more' module, not just the > functions. This includes such things as __name__, __doc__, __file__. > Could have interesting side-e

Re: Function to import module to namespace

2008-06-29 Thread John Machin
On Jun 30, 9:52 am, bvdp <[EMAIL PROTECTED]> wrote: > Terry Reedy wrote: > > > > > > > > > > Do you mean something like this? > > > > > >>> math.__dict__.update(string.__dict__) > > >>> dir(math) > > ['Formatter', 'Template', '_TemplateMetaclass', '__builtins__', > > > > I think t

Re: Function to import module to namespace

2008-06-29 Thread bvdp
Terry Reedy wrote: > > > Do you mean something like this? > >>> math.__dict__.update(string.__dict__) > >>> dir(math) > ['Formatter', 'Template', '_TemplateMetaclass', '__builtins__', I think this is working First off, 2 module files: funcs.py def func1(): print "I'm func1

Re: Function to import module to namespace

2008-06-29 Thread bvdp
Terry Reedy wrote: bvdp wrote: Is it possible to do this from a function: import a module and append the defs in that module to an existing module/namesapce. So, in my code I have something like: # main code import mods def loadmore(n): import_module(n, mods) # end of main this

Re: Function to import module to namespace

2008-06-29 Thread Terry Reedy
bvdp wrote: Is it possible to do this from a function: import a module and append the defs in that module to an existing module/namesapce. So, in my code I have something like: # main code import mods def loadmore(n): import_module(n, mods) # end of main this will permit the add

Re: Function to import module to namespace

2008-06-29 Thread Cédric Lucantis
Le Sunday 29 June 2008 21:08:36 bvdp, vous avez écrit : > Is it possible to do this from a function: import a module and append > the defs in that module to an existing module/namesapce. > > So, in my code I have something like: > > # main code > import mods > > def loadmore(n): > import_module

Function to import module to namespace

2008-06-29 Thread bvdp
Is it possible to do this from a function: import a module and append the defs in that module to an existing module/namesapce. So, in my code I have something like: # main code import mods def loadmore(n): import_module(n, mods) # end of main this will permit the addition of the th