logoalt Hacker News

13hunteotoday at 9:23 AM1 replyview on HN

If you want to handle the three cases individually using your implementation, you would have to make another function call, rather than just the one


Replies

globular-toasttoday at 10:43 AM

You don't, although it is perhaps quite awkard:

    message.is_blatant_spam  # true if blatant spam
    message.is_spam and not message.is_blatant_spam  # true if possibly spam
    not message.is_spam  # true if not spam
But there's nothing stopping adding that middle one as another property, again without breaking compatibility:

    @property
    def is_possibly_spam(self) -> bool:
       return self.is_spam and not self.is_blatant_spam
The point is, you don't actually have to break compatibility here, you can just define more predicates to add the extra granularity without breaking the existing ones.