On Wed, Feb 20, 2019 at 10:18 AM Steven D'Aprano <st...@pearwood.info> wrote: > So the promises made will nearly always be incredibly weak: > > - raises(A) means "may raise A, or any other unexpected exception" > - sideeffects(True) means "may have expected side-effects" > - sideeffects(False) means "may have unexpected side-effects"
Perhaps, but sometimes it's nice to know that a function is not intended to have any side effects. For instance, I'm currently working on some code that has a bunch of lines like this: type = _decode("WeaponTypes" if is_weapon else "ItemTypes") balance = _decode("BalanceDefs") brand = _decode("Manufacturers") Suppose we decide that the "balance" variable isn't being used anywhere. Is it okay to not decode the BalanceDefs? Nope, it isn't, because the decoding is done sequentially, which means that omitting one will leave all the subsequent ones desynchronized. Knowing that a function has no intentional side effects (which is weaker than declaring that it's a pure function) may well be useful when refactoring a messy codebase. (A messy codebase, such as the one that I was reading through when building that code. It's not code I'm intrinsically proud of, but I can say with confidence that it is WAY cleaner than the reference code. And if I'd been able to ascertain which functions were pure, or at least side-effect-free, it would have saved me a lot of hassle.) ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/