Created
February 6, 2018 09:36
-
-
Save RonnyPfannschmidt/43e74c8be8e1bda3f50545e7bc9e8c64 to your computer and use it in GitHub Desktop.
pseudocode for refactoring moves of partial match, not tested
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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