best way to read a configuration file

Paul McGuire bogus at bogus.net
Tue Mar 9 09:31:47 CET 2004


"cmkl" <cmkleffner at gmx.de> wrote in message
news:3b091a1c.0403080738.12a457bd at posting.google.com...
> Paul,
>
> do you have a jython compatible pyparsing version?.
> I tried to modifiy pyparsing for jython-2.2a0 without
> success (jython still doesnt support newstyle classes)
>
> Regards
>
> Carl
>
>
> "Paul McGuire" <bogus at bogus.net> wrote in message
news:<1qj1c.29893$qo.16145 at fe1.texas.rr.com>...
> >
> > pyparsing also comes with an expression parser and evaluator in its
> > examples.  With some creative merging of the two, I think you could in
> > fairly short order have a config parser that would handle your Na = K+2
and
> > res_file = "$result_dir..." config values.
> >
> > The pyparsing home page is at http://pyparsing.sourceforge.net.
> >
> > HTH,
> > -- Paul
Carl -

I wrote a converter (using pyparsing) to replace all of the super() calls to
explicit superclass calls, and remove the inheritance from object.  Now I
get strange TypeError exceptions like this:

Traceback (most recent call last):
  File "pyparsingForJython.py", line 1276, in ?
    test( "SELECT * from XYZZY, ABC" )
  File "pyparsingForJython.py", line 1250, in test
    tokens = simpleSQL.parseString( teststring )
  File "pyparsingForJython.py", line 313, in parseString
    loc, tokens = self.parse( instring.expandtabs(), 0 )
  File "pyparsingForJython.py", line 278, in parse
    loc,tokens = self.parseImpl( instring, loc, doActions )
  File "pyparsingForJython.py", line 758, in parseImpl
    resultlist += exprtokens
TypeError: 'str' object is not callable

So this is mystifying to me - in this particular case, resultlist and
exprtokens are both ParseResults objects, and there is a defined __iadd__
method - is operator overloading also part of newstyle classes?  Also, I
suspect we would need to remove the scanString() method, since this uses
generators, and I would guess Jython doesn't support those, either.

Overall, I am not optimistic at the chances of getting pyparsing working
with Jython... :(

-- Paul





More information about the Python-list mailing list