twoframesperminute

joined 1 year ago
[–] [email protected] 0 points 10 months ago (5 children)

@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.

[–] [email protected] 0 points 10 months ago* (last edited 10 months ago) (7 children)

@sugar_in_your_tea But isn't all that possible in Python? Don't monads cover exactly what you want? Why does it need to be implemented some different way?

Also, divide by zero should be data just as well. Failing to program around having nothing to divide by is not a reason to have a program panic.

Also, having two systems for largely the same behavior doesn't seem to improve usability and clarity, in my opinion.

[–] [email protected] 0 points 10 months ago (9 children)

@sugar_in_your_tea I'm by far not qualified to discuss this in depth. But it seems to me that almost every function call ever can fail. Therefore, do you need to do this with every single function call?

That seems terribly inefficient and bloated. How is that readable for anyone?

[–] [email protected] 0 points 10 months ago (11 children)

@sugar_in_your_tea The idea of exceptions is that you can choose when to deal with them. So if you want to deal with them immediately,
nothing is stopping you.

If you think handling errors with every function call explicitly is easier, I guess you're using very few functions. For the project I'm working on, your proposal would probably double the number of lines. Thanks, but no thanks.

[–] [email protected] 1 points 10 months ago (13 children)

@sugar_in_your_tea If you're expecting exceptions, make custom ones. That's the best way to distinguish between those you expect and those you don't. Using custom exceptions improves readability too.

[–] [email protected] 1 points 10 months ago (1 children)

@onlinepersona It looks sleek and says it does everything. Reason enough to keep away.

[–] [email protected] 1 points 11 months ago

@danielquinn agreed! You can work around the performance issues by wrapping it in a function.

[–] [email protected] 0 points 1 year ago* (last edited 1 year ago) (1 children)

@nikaro iterable means: has __iter__() method. So there's no real difference, as far as I can see.

view more: ‹ prev next ›