Add assignment operator to assign values in the middle of pipelines
See original GitHub issueFor example, we have this pipeline:
3 |> x -> x**2 |> y -> y/3 |> print
which gives us the result 3 |> 9 |> 3 |> 3
. Sometimes we may want to get the value in the middle, say 9
in the above example and assign it to a variable so we can use it later (e.g. debugging).
I don’t know if something like the following possible?
3 |> x -> x**2 =: a |> y -> y/3 |> print$(a, ?)
# 9, 3
or
3 |> x -> x**2 => a |> y -> y/3 |> print$(a, ?)
# 9, 3
Thank you evhub
and all the contributors for making a great language. Piping and compositing really make Python more fun =D
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Pipe with assignment | pipeR Tutorial
If one needs to assign the value to a symbol, just insert a step like (~ symbol) , then the input value of...
Read more >Assignment operators - assign an expression to a variable
The assignment operator = assigns the value of its right-hand operand to a variable, a property, or an indexer element given by its...
Read more >Assignment (=) - JavaScript - MDN Web Docs - Mozilla
The assignment operation evaluates to the assigned value. Chaining the assignment operator is possible in order to assign a single value to multiple...
Read more >Assignment Operators - Developer Help
The simple assignment operator "=", assigns the value on its right to the variable on its left. Compound Assignment. variable = variable op...
Read more >Assignment and Compound Assignment
The assignment statement stores a value in a variable. Compound assignment combines assignment with another operator.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
See issue #489.
Note to anyone in the future trying to use the assignment operator
:=
: This only works in Python 3.8, so you need to pass the--target 38
to Coconut. Then make sure your interpreter is 3.8+ or you’ll end up with: