3 ms·
You can make any code unintuitive by naming the variables wrong. Consider: LAST_MATCHED_STATUS_CODE = 404 match status_code: case LAST_MATCHED_
by bondarchuk 6y ago
You can make any code unintuitive by naming the variables wrong. Consider:
LAST_MATCHED_STATUS_CODE = 404
match status_code:
case LAST_MATCHED_STATUS_CODE:
print("HTTP Not Found")
- ma2rten 6y agoThat's still unintuitive or at least strange because uppercase generally indicates constants.
- pansa2 6y agoRenaming the variable doesn’t fix the code. It still prints “HTTP Not Found” for every value of `status_code`.
- bondarchuk 6y agoright.. D'oh I gather that the proposed solution is to use something like enums? Or not do this at all?
- masklinn 6y agoYes, or not import the constants from their module aka import foo not from foo import BAR, BAZ, QUX