Bottom Page

Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Walrus Operator in 3.8
#1
https://medium.com/hultner/try-out-walru...30ce0ce601

Seems pretty cool for buffers.
# instead of...
buffer = create_buffer()
while True:
    chunk = buffer.read()
    if not chunk:
        break
    process(chunk)

# ...you'll be able to do this:
buffer = create_buffer()
while chunk := buffer.read():
    process(chunk)
Quote
#2
I freaking love the name. Also walruses are fairly ugly so maybe it encourages using it as sparingly as it probably ought to be used :)
buran likes this post
Quote
#3
I don't know. It seems ugly.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Quote
#4
in a matter of 10 minutes of researching this im having mixed emotions. At first i was disgusted, then intrigued. Now I might even like it.

Is this a common operator in some other languages? I cant seem to find much about it other than python.
Quote
#5
Isn't this what Guido quit over?
Don't know if I will like it or not, and won't until I find a need for it.
the example above, looks somewhat pretty, not ugly to me.

So far, I don't really have a feeling one way or the other.
Quote
#6
I saw definite uses for it when writing t_games, but I don't want t_games to be dependent on the latest version.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#7
(Feb-15-2019, 08:42 PM)metulburr Wrote: Is this a common operator in some other languages? I cant seem to find much about it other than python.
In C/C++ at least, the assignment operator is an expression, rather than a statement like Python, so basically yes C/C++ have this operator but Python is different in the sense that it's two different things instead of one thing. I believe Java assignments are also expressions, though the usefulness is less in Java than C/C++.
Quote
#8
(Feb-15-2019, 08:48 PM)Larz60+ Wrote: Isn't this what Guido quit over?
It was the straw that broke his back. He didn't quit over just this, but the way the community reacted pushed him over the edge.

Guido is the one who wanted this to happen. The pushback he got was too much for him to take.

The reason Python didn't have this ability from the start, like C/C++, was to avoid ambiguity in equality checks. That's why there's alternate syntax for it now, so there's still no ambiguity over what's happening.
Quote
#9
(Feb-16-2019, 04:29 PM)nilamo Wrote: The pushback he got was too much for him to take.

Programmers can be such uptight purists sometimes. Every CS degree should have a mandatory class named CS 305: You Really Need to Lighten Up.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#10
Quote:Programmers can be such uptight purists sometimes
Don't we all strive for excellence?
It's part of the job.
My wife has another name for it, which I won't mention here.
The fact that everything in a properly functioning program, in the end, has to be either true or false leads us to be pricks!
There's no maybe gate on a chip! (Perhaps on a multi-vibrator?)
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  lambda or operator? ichabod801 1 193 Jun-03-2019, 02:42 AM
Last Post: scidam
  shift operator on lists Skaperen 3 542 Sep-09-2018, 02:38 AM
Last Post: ichabod801
  Operator Precedence Direction in Docs blitz4 3 735 Mar-11-2018, 06:15 AM
Last Post: wavic

Forum Jump:


Users browsing this thread: 1 Guest(s)