Patterns matching for python