Re: Best way to print a module?

2011-09-05 Thread Steven D'Aprano
Tim Roberts wrote: > Martin De Kauwe wrote: >> >>If I wanted to print an entire module, skipping the attributes >>starting with "__" is there an *optimal* way? > > Your question is somewhat ambiguous. When I read "print an entire > module", I assumed you were asking for a way to print the sourc

Re: Best way to print a module?

2011-09-05 Thread Martin De Kauwe
Trying to follow the suggestion this would be the alternate implementation. import sys sys.path.append("/Users/mdekauwe/Desktop/") import params #params.py contains #apples = 12.0 #cats = 14.0 #dogs = 1.3 fname = "test.asc" try: ofile = open(fname, 'w') except IOError: raise IOError("Can

Re: Best way to print a module?

2011-09-05 Thread Martin De Kauwe
Hi, Tim yes I had a feeling my posting might be read as ambiguous! Sorry I was trying to quickly think of a good example. Essentially I have a set of .ini parameter files which I read into my program using configobj, I then replace the default module parameters if the user file is different (in my

Re: Best way to print a module?

2011-09-05 Thread Tim Roberts
Martin De Kauwe wrote: > >If I wanted to print an entire module, skipping the attributes >starting with "__" is there an *optimal* way? Your question is somewhat ambiguous. When I read "print an entire module", I assumed you were asking for a way to print the source code, perhaps with syntax co

Re: Best way to print a module?

2011-09-05 Thread rantingrick
On Sep 5, 10:06 am, Martin De Kauwe wrote: > Hi, > > If I wanted to print an entire module, skipping the attributes > starting with "__" is there an *optimal* way? Currently I am doing > something like this. Note I am just using sys here to make the point > > import sys > > data = [] > for attr in

Best way to print a module?

2011-09-05 Thread Martin De Kauwe
Hi, If I wanted to print an entire module, skipping the attributes starting with "__" is there an *optimal* way? Currently I am doing something like this. Note I am just using sys here to make the point import sys data = [] for attr in sys.__dict__.keys(): if not attr.startswith('__') and no