Rewriting a 20-year-old Python library

(b-list.org)

14 pontos | por PaulHoule 5 dias atrás

2 comentários

  • est
    11 horas atrás
    > There is a trend of libraries and frameworks providing both sync and async code paths in the same class, often using a naming scheme which prefixes the async versions of the methods with an a

    I have a solution to write a single Python function for both async/sync

    https://news.ycombinator.com/item?id=43982570

    • LtWorf
      10 horas atrás
      I don't really understand what that does.
  • globular-toast
    12 horas atrás
    The binary "is spam" thing seems like a non-issue, unless I'm misunderstanding something. In Python you can easily implement Boolean attributes using predicates without breaking the API, like so:

        @property
        def is_spam(self) -> bool:
           return self._comment_check in {"true", "blatant"}
    
    Then you can simply add another predicate to support the blatant case:

        @property
        def is_blatant_spam(self) -> bool:
           return self._comment_check == "blatant"