This is a discussion on Python’s forums about adding something akin to a throws keyword in python.

  • twoframesperminute@mastodon.social
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    @sugar_in_your_tea Since when is Python supposed to equal pseudo code? It should be easily readable, but that doesn’t mean it should *equal* pseudo code.

    You can either test for values being 0 before dividing, or catching an exception when it is. Especially when dividing multiple times in one function, I would go for the latter option.

    • twoframesperminute@mastodon.social
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      @sugar_in_your_tea I don’t think we should change any functionality when it comes to exception handling. Code based documentation would be great for type checking and auto-generated docs, but they can be done using annotations, not changed interfaces.

      Monads are already possible, but should not be the normal way to code either. It’s clunky and difficult to understand. It might work great for some scenarios, but doesn’t for many others.