Re: creating a list of all imported modules

2009-03-10 Thread John Machin
On Mar 11, 1:29 am, Timmie wrote: > > Put this code at the end of your script: > >     import sys > >     info = [(module.__file__, name) > >         for (name, module) in sys.modules.iteritems() > >         if hasattr(module, '__file__')] > >     info.sort() > >     import pprint > >     pprint.p

Re: creating a list of all imported modules

2009-03-10 Thread Gabriel Genellina
En Tue, 10 Mar 2009 12:29:28 -0200, Timmie escribió: Put this code at the end of your script: import sys info = [(module.__file__, name) for (name, module) in sys.modules.iteritems() if hasattr(module, '__file__')] info.sort() import pprint pprint.pprint(in

Re: creating a list of all imported modules

2009-03-10 Thread Timmie
> Put this code at the end of your script: > import sys > info = [(module.__file__, name) > for (name, module) in sys.modules.iteritems() > if hasattr(module, '__file__')] > info.sort() > import pprint > pprint.pprint(info) > > AFAIK unless someone has been mess

Re: creating a list of all imported modules

2009-03-10 Thread John Machin
On Mar 10, 11:01 am, Tim Michelsen wrote: > Hello, > > how do I create a list of all modules imported by my module/script and > which are present in the namespace? > > I am looking for something like %who in Ipython. > > My aim is to create a file for the documentation that shows all > dependencie

Re: creating a list of all imported modules

2009-03-10 Thread Duncan Booth
mat...@gmail.com wrote: for i in dir() : > ... t = eval( 'type(' + i + ')' ) > ... if re.match('.*module.*',str(t)) : print i, t > ... If you think you need eval stop and think again. You don't. If you think you need regular expressions stop and think again. You usually don't. >>> def

Re: creating a list of all imported modules

2009-03-09 Thread mataap
On Mar 10, 10:01 am, Tim Michelsen wrote: > Hello, > > how do I create a list of all modules imported by my module/script and > which are present in the namespace? > > I am looking for something like %who in Ipython. > > My aim is to create a file for the documentation that shows all > dependencie

creating a list of all imported modules

2009-03-09 Thread Tim Michelsen
Hello, how do I create a list of all modules imported by my module/script and which are present in the namespace? I am looking for something like %who in Ipython. My aim is to create a file for the documentation that shows all dependencies of my script on external (3rd party) libraries. T