Hacker News new | ask | show | jobs
by gremlinsinc 1912 days ago
I think a better format would be:

instead of:

    p(2 * 3 * 7)  #=> 42
      ^^^^^var
Having:

   p(var1:[2*3] * var2: 7) => 42

   p(var1) => 6

   p(var2) => 7 
The other requires ugly whitespacing.
1 comments

It kind of works in Python 3.9 and perhaps earlier, unfortunately need extra parentheses ...

  >>> print((v1 := 2 * 3) * (v2 := 7))
  42
  >>> print(v1)
  6
  >>> print(v2)
  7
edit: formatting