would add that the default value itself (the literal string "N/A") is a code smell, as it seems to be mixing presentation with business logic. If this is actually a presentation layer, at the very least it should be using gettext or similar
True. Python has None, so why use "N/A" here? Or if that is not explicit enough, do MISSING_VALUE = object().
Bonus points would have been given, if one of the literals would be "NA" by typo :)
Rant: I'd really like for Python to have type-safe named symbols, i.e. an equivalent of MISSING_VALUE = object where repr(MISSING_VALUE) == "MISSING_VALUE" and, ideally, str(MISSING_VALUE) -> Exception.
View all comments
Show parent comment
4
u/knightwhosaysnil Jul 14 '21
would add that the default value itself (the literal string "N/A") is a code smell, as it seems to be mixing presentation with business logic. If this is actually a presentation layer, at the very least it should be using gettext or similar