More generic handling of functions and methods in Python highlighter