Using ConfigParse
Zunbeltz Izaola
zunbeltz at wm.lc.ehu.es.XXX
Tue Jun 8 07:14:04 EDT 2004
Peter Otten <__peter__ at web.de> writes:
> Zunbeltz Izaola wrote:
>
> > def save(self):
> > print "Enter save"
> > self.write(open('defaultdifrac.cfg','w'))
> > self.read(open('defaultdifrac.cfg'))
> > print "OUt save"
>
> I would explicitly close the file before trying to read it.
>
> >>> def save(fn="tmp.txt", s="so what", close=True):
> ... f = file(fn, "w")
> ... f.write(s)
> ... if close: f.close()
> ... return file(fn).read()
> ...
> >>> save()
> 'so what'
> >>> save(s="another")
> 'another'
> >>> save(s="yet another", close=False)
> ''
Thanks for the sugestion but it doen't work, i don't know wy
CofigParser doesn't write the file
Zunbeltz
>
> Peter
>
--
Zunbeltz Izaola Azkona | wmbizazz at lg dot ehu
dotes
Materia Kondentsatuaren Fisika Saila |
Zientzia eta Teknologia Fakultatea | Phone: 34946015326
Euskal Herriko Unibertsitatea |
PK 644 | Fax: 34 944648500
48080 Bilbo (SPAIN) |
More information about the Python-list
mailing list