erikrose / parsimonious

The fastest pure-Python PEG parser I can muster
MIT License
1.82k stars 128 forks source link

Type check when comparing nodes #98

Closed cknv closed 8 years ago

cknv commented 8 years ago

This should close #95 by making the Node give up comparisons with things that are not of its class.

I went with returning NotImplemented as that gives other a chance to do the comparison.

I thought about using

if not isinstance(other, type(self)):
    ...

But I don't really know what is the preferred style, so I just went with the simpler.

erikrose commented 8 years ago

Thanks again for the good patch! :-D

wiseman commented 8 years ago

I didn't know about the NotImplemented technique, nice.