[pyar] [Fwd: Re: Escribir en un archivo con ConfigParser]

Página superior
Adjuntos:
+ (text/plain)

Responder a este mensaje
Autor: craf
Fecha:  
A: Python Argentina
Asunto: [pyar] [Fwd: Re: Escribir en un archivo con ConfigParser]
--------- Mensaje reenviado --------
> De: Mario Colque <colquemario@???>
> Reply-to: Python Argentina <pyar@???>
> Para: Python Argentina <pyar@???>
> Asunto: Re: [pyar] Escribir en un archivo con ConfigParser
> Fecha: Wed, 29 Dec 2010 00:05:49 -0300
>
> 2010/12/28 marco bernich <marcobernich@???>:
> >
> >
> > 2010/12/28 marco bernich <marcobernich@???>
> >>
> >>
> >> 2010/12/28 craf <prog@???>
> >>>
> >>> Hola.
> >>>
> >>> Estoy tratando de escribir en un archivo conf, utilizando para ello el
> >>> modulo ConfigParser.
> >>>
> >>> El código es el siguiente:
> >>>
> >>> import ConfigParser
> >>>
> >>>
> >>> cfg = ConfigParser.ConfigParser()
> >>> cfg.set('f_main', 'firstime', '128')
> >>> f = open('config.conf', 'w')
> >>> cfg.write(f)
> >>> f.close()
> >>>
> >>> Pareciera estar bien, pero me arroja error diciendome que no encuentra
> >>> la seccion f_main.
> >>
> >> puede ser por ésto?
> >> http://docs.python.org/library/configparser.html
> >>
> > es decir, que versión de python estás usando?
> >
> > _______________________________________________
> > pyar mailing list pyar@???
> > http://listas.python.org.ar/listinfo/pyar
> >
> > PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
> >
> creo que te estas olvidando de:
>
> cfg.add_section("f_main")
>
> osea que quede:
>
> cfg = ConfigParser.ConfigParser()
> cfg.add_section("f_main")
> cfg.set('f_main', 'firstime', '128')
> f = open('config.conf', 'w')
> cfg.write(f)
> f.close()
>

Muchas gracias Mario!, era lo que me faltaba.

Saludos.

CRAF


_______________________________________________
pyar mailing list pyar@???
http://listas.python.org.ar/listinfo/pyar


PyAr - Python Argentina - Sitio web: http://www.python.org.ar/