In lots of functional languages, you’d have some_function() return an Option type and then you’d use .map() or similar on it to only do something when the value is defined. I think, that can be done in Python’s syntax, but you need a library for the Option type…
Python has an “Optional” type, but it’s merely an alias for T | None. I wish Python had better support for FP, but each time it gets close, it doesn’t quite go far enough.
For example, it now has match blocks, but there’s no error if the match is exhaustive, which hurts formal proofs of correctness. Likewise, tons of other features fall a bit short, but in general it’s workable with some discipline.
In lots of functional languages, you’d have
some_function()
return anOption
type and then you’d use.map()
or similar on it to only do something when the value is defined. I think, that can be done in Python’s syntax, but you need a library for theOption
type…Python has an “Optional” type, but it’s merely an alias for
T | None
. I wish Python had better support for FP, but each time it gets close, it doesn’t quite go far enough.For example, it now has
match
blocks, but there’s no error if the match is exhaustive, which hurts formal proofs of correctness. Likewise, tons of other features fall a bit short, but in general it’s workable with some discipline.