class OutFile:
def __init__(self, fn):
+ self.filename = fn
if fn==None:
self.file = sys.stdout
else:
pstr = ""
for p in params:
if type(p)==float:
- pstr += " %.6g"%p
+ pstr += " %#.6g"%p
else:
pstr += " %s"%p
return "%s%s"%(kwd, pstr)
def end(self):
self.indent -= 1
self.file.write("%s};\n"%('\t'*self.indent))
+
+
+def open_output(f):
+ if isinstance(f, OutFile):
+ return f
+ return OutFile(f)