[Baypiggies] Reading k=v format files

malcolm malcolm at hoprocker.net
Sun Oct 4 00:55:31 CEST 2015


Also, don't forget your friend execfile(<path_to_file>,
[<optional_dictionary>]) -- if the bash settings are already in a format
that can be construed as Python values, then you're on your way.

On Sat, Oct 3, 2015 at 1:04 PM, Ian Zimmerman <itz at buug.org> wrote:

> On 2015-10-03 12:09 -0700, David Berthelot wrote:
>
> > The module ConfigParser in the standard library could be of help since it
> > seems to do exactly this:
> > https://docs.python.org/2/library/configparser.html
>
> Sadly, no.
>
> $ python
> Python 2.7.3 (default, Mar 13 2014, 11:03:55)
> [GCC 4.7.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import ConfigParser as CP
> >>> p=CP.RawConfigParser()
> >>> p.read('auth')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/usr/lib/python2.7/ConfigParser.py", line 305, in read
>     self._read(fp, filename)
>   File "/usr/lib/python2.7/ConfigParser.py", line 512, in _read
>     raise MissingSectionHeaderError(fpname, lineno, line)
> ConfigParser.MissingSectionHeaderError: File contains no section
> headers.
> file: auth, line: 1
>
> --
> Please *no* private copies of mailing list or newsgroup messages.
> Rule 420: All persons more than eight miles high to leave the court.
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> https://mail.python.org/mailman/listinfo/baypiggies
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20151003/f1b1bb5d/attachment.html>


More information about the Baypiggies mailing list