Skip to content

Instantly share code, notes, and snippets.

@RonnyPfannschmidt
Created February 6, 2018 09:36
Show Gist options
  • Save RonnyPfannschmidt/43e74c8be8e1bda3f50545e7bc9e8c64 to your computer and use it in GitHub Desktop.
Save RonnyPfannschmidt/43e74c8be8e1bda3f50545e7bc9e8c64 to your computer and use it in GitHub Desktop.
pseudocode for refactoring moves of partial match, not tested
# step 1 - evil __new__, maybe unnecessary
class partial_match(object):
def __new__(cls, str_to_match):
if str_to_match is None:
return None
return cls(str_to_match)
# step2 constructor function, may need protection against regression
def partial_match(str_to_match, _matcher_cls=PartialMatcher):
if str_to_match is None:
return None
return _matcher_cls(str_to_match)
@attr.s
class PartialMatcher(object):
part_string = attr.ib()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment