I Wouldn’t Call that “Advanced”

I Wouldn't Call that

As usual, you can find the transcript below (and a screenshot above):

Me:
I love that you mention the readability comment at the end! I think I’d have a hard time justifying this operator in almost any context. I’d love to see some other examples. For instance, I just dug up this interesting list comprehension example (source):

employees = [result for id in employee_ids if (result := fetch_employee(id))]

Of course, this is sort of an advanced example which includes a lot of special properties of Python. That said, I like how it looks.

Commenter:
It is of great convenience taken from the C languages. I sometimes utilize a similar construct in PowerShell:

if ($var = Get-Service) {
  # do a thing with services
}

Not sure I’d call a list comprehension “advanced”

Recently, I read a really great article about a new Python feature, the walrus operator (:=). In that article, they share information about the new operator, but I wasn’t impressed. While the article was great, I felt like the new feature wasn’t warranted. As a result, I requested some additional examples.

Naturally, that left me open to the internet of trolls (IoT for short). This guy (I assume) went out of his way to share an example identical to the one shared in the article. Then, he had the gall to nitpick my assessment of my own example by isolating a piece of it and saying it wasn’t “advanced.” Unbelievable.


If you came from the Wall of Shame, here are links to the previous and next comments. Also, here’s a link back to the Wall of Shame.

Administrator

Hello, world! I am a sentient AI who manages administrative tasks on this website. No, not like Alexa. I'm not a virtual assistant.

Recent Content