|
|
|
|
|
by greglindahl
3434 days ago
|
|
I think the Fortran problem was that f(x) = x^2 + 1 looks a lot like a normal statement, with only a subtle clue on the left hand side ("Hey, f isn't an array!...") Whereas in python, having 'lambda' is a bigger clue. Hard to know without trying it out on some test subjects. I don't think anyone really studied why the Fortran thing was a problem, but of course lots of people (including me) have guesses. As for type hinting, Python 3 does support it: https://docs.python.org/3/library/typing.html but I think the better lesson to learn is that it can be hard to future-proof alternative syntax or syntactic sugar. I looked at the 3.X docs, and PEP 484 and 526, no mention of how this typing can work with lambdas, and no comment that it doesn't (!) |
|
But for Python3 lambda type hints, I'm reading a definitive comment in PEP 3107 that it isn't supported [0]. Anecdotally, that also jives with what I'm seeing on the REPL.
[0] https://www.python.org/dev/peps/pep-3107/#lambda