On 5/20/21 1:58 AM, Chris Angelico wrote: > On Thu, May 20, 2021 at 2:02 PM Richard Damon <rich...@damon-family.org> > wrote: >> Given the following definition of classes, I am getting an unexpected >> error of : >> >> TypeError: __init__() missing 2 required keyword-only arguments: >> 'idcode' and 'tag' >> >> On the call to create a GedcomHead in the call to GedcomHead() in >> Gedcom0Tag.add() >> >> class Gedcom0Tag(GedcomTag): >> """Represents a Level 0 Tag of a GEDCOM file""" >> >> @classmethod >> def add(cls, *, parent, tag: str, payload: str, level=0): >> >> Gedcom0Tag.add(parent, 'Head', '') >> > You're defining that add takes keyword-only args (because the asterisk > stops them from being passed positionally), but then you're calling it > with nothing but positional args. Is that the code you're using? I > would expect to see *three* missing kwonly args from this. > > ChrisA
The last line wasn't copied but distiled from the rest of the code to simplify the segment. The actual code had the parameters named in the call. Peter found the error with too many underscores on init. -- Richard Damon -- https://mail.python.org/mailman/listinfo/python-list