4 ms·
The problem is that `NOT_FOUND` behaves differently from the literal `404`, which breaks an important principle: “if you see an undocumented constant, you can a
by pansa2 6y ago
The problem is that `NOT_FOUND` behaves differently from the literal `404`, which breaks an important principle: “if you see an undocumented constant, you can always name it without changing the code’s meaning” [0].
[0] https://twitter.com/brandon_rhodes/status/1360226108399099909 https://twitter.com/brandon_rhodes/status/136022610839909990...
- masklinn 6y agoThat is true, but for Python never having had constants. So as soon as you name an undocumented constant, you run the risk that people will update it. So that's less a principle and more a guideline. And hey, if it finally gets explicit variable declarations in Python I'm 100% all for it. implicit locals, `global`, and `nonlocal` are awful, viva `let` and `const` or whatever. As to the content of the tweet > The Substitution Principle, learned in algebra? Python is not algebra, and already breaks algebraic reasoning to and through. Just consider that `a = a + b` and `a += b` are completely different operations with possibly (and actually, for some types) completely different effects.
- pansa2 6y ago> `a = a + b` and `a += b` are completely different operations Getting off-topic, but IMO that’s a major design flaw in the language. Some others agree, e.g. https://twitter.com/joepolitz/status/1304992696293978112 https://twitter.com/joepolitz/status/1304992696293978112
- masklinn 6y agoOh I completely agree it’s a major design flaw of the langage and I was dismayed the core devs used it again with the in-place dict update of 3.9. My point was that if you were teaching people that pull thon follows strict algebraic principles you were already setting them up for a rude series of surprises.