[Python-Dev] Is PEP 572 really the most effective way to solve the problems it's targeting?
Steven D'Aprano
steve at pearwood.info
Thu Apr 26 20:58:16 EDT 2018
On Thu, Apr 26, 2018 at 09:36:48AM -0700, Mike Miller wrote:
> However, there were two good questions in this message which I haven't seen
> addressed yet:
>
> - How are other modern languages solving this issue?
> - How does this new construct intersect with typing functionality?
What counts as a modern language? Less than five years old? Less than
fifty years old? Are Javascript, Ruby and R modern? They all support
assignment as expressions.
I think Koitlin, Rust and Go prohibit assignment as expressions.
Swift assignment evaluates as Void (equivalent to None in Python, I
guess), so you can use assignment in an expression but it returns
nothing and only operates by side-effect.
As far as type hints go, I think that if you need explicit type hints in
the middle of an expression, it's a bad idea and you ought to pull it
out as a separate statement. That applies regardless of whether that
expression involves binding or not.
--
Steve
More information about the Python-Dev
mailing list