Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library
← Back to context

Comment by Balinares

5 days ago

Mainly I disliked the walrus operator because Python already has a keyword that means "capture the output of this clause into this variable": as.

E.g.,

    try:
        with open("file.txt") as f:
            do_something(f)
    except OSError as e:
        print(e)

And now:

    L = [abs(x) as x_abs for x in some_list if x_abs < 10]

0 comments

Balinares

Reply

No comments yet

Contribute on Hacker News ↗

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities