0

I am using plyplus and just trying to get the debug option turned on.

The Grammar class is defined like:

class Grammar(object):
    def __init__(self, grammar, **options)

and I am invoking it via

options = { 'debug' : True }
Grammar(long_string, options)

but I get this error:

TypeError: __init__() takes exactly 2 argument (3 given)

I am going mad looking at this; what's wrong? This is using Python 2.7 on Ubuntu and I verified that there is no older version of plyplus on the system with one fewer argument.

TigerhawkT3
  • 48,464
  • 6
  • 60
  • 97
Mark McWiggins
  • 621
  • 6
  • 20
  • 7
    You are passing `options` as a single argument: a dictionary. What you should be doing is passing the items of the dictionary as keyword arguments. To do that, use `**options`. – zondo Aug 17 '16 at 04:11
  • See https://stackoverflow.com/questions/9867562/pass-kwargs-argument-to-another-function-with-kwargs – zondo Aug 17 '16 at 04:13

1 Answers1

0

Zondo's answer worked for me:

Grammar(mylongstring, **options)

I've been using Python for some years but never came across this before.

Thanks!

Mark McWiggins
  • 621
  • 6
  • 20