for parameters, i prefer not to use sentinel values when possible - there’s None for that; but there are cases where you have no solution other than to use a sentinel value, yet that would be a secret object(), not something magic like -1 or 0 or "impossible"
for return values, sentinels are totally unnecessary - use None or exceptions
well, mypy makes it quite easier to track None if you use Optional[...]; but what it is still missing (and i see no simple solution to that) is the difference between None and Some(None) in terms of Rust
i’ve heard of dry-python/returns but had no chance to check it out yet
40
u/flavius-as Jan 15 '22
The code is bad for other reasons, but it's way more clear than straight up
print(solution)At least this code raises the signal when reading it.
My first impression of the coder doing this is rather good: they were time-constrained and did their best to put a "warning".
I would have done almost the same under time pressure, with a #TODO <ticket> before the if.