4 ms·
If you change an operation that is meant to return a Boolean to return anything else, you are insta fired.
by pbalau 2mo ago
If you change an operation that is meant to return a Boolean to return anything else, you are insta fired.
- echoangle 2mo agoYou mean like the numpy authors that let the comparison operators return arrays? Also, apparently SQLAlchemy does exactly what I proposed so apparently they are erring in their ways too. I honestly don’t find it that bad.
- vtbassmatt 2mo agoI would have agreed with this, and then they did the `pathlib.Path` bit of cuteness with the `/` operator: https://github.com/python/cpython/blob/5afbb60e0283caaf34990bbe8437111ebaae04a4/Lib/pathlib/__init__.py#L175 https://github.com/python/cpython/blob/5afbb60e0283caaf34990... And despite my misgivings, it’s really ergonomic.
- pbalau 2mo agoIf you divide a Path by another Path, you get a Path. If you compare two Paths, you get a Boolean. It is not really the same.
- BrenBarn 2mo agoThat's a well established pattern in Python, for instance with Numpy. That's the point. Operations in Python aren't "mean to return" anything in particular. Each class can define the operations as it wants. That's a powerful feature that allows creation of specialized expression languages, as used by other ORMs besides Django.
- zzzeek 2mo agoHi, don't mind me, but You don't need to return a boolean. You need to return an object that implements __bool__. Get it ? And even then, when you're dealing with objects that are special to expressions, you don't actually even need __bool__ that much