Hacker News new | ask | show | jobs
by kriro 4481 days ago
Why are there so many negative comments? Maybe those posters are vastly underestimating how many people that just start out read HN. I think it's a pretty good post to read after something like "X in Y minutes - Python" to get a very quick grasp of what the language is like.

I'm also not ashamed to say that despite having written quite a few LOC of Python I wasn't aware of named slices for some reason and I think they can clear up some chunks of code I have produced (make it more readable)

5 comments

I've been programming in Python for about 3 years and learned a couple of tricks from this post, which was why I submitted it.

There's always tricks to learn, and it's hard to remember everything when you're first starting out with a new language.

Extended unpacking was a new one on me. Kind of like a simple version of pattern matching. I think this one will prove useful!

(I've been using python for many years, but not full time. It's the language I use for one-off scripts, small tools that make use of its handy standard library, or prototypes for things I'm going to write in some other language. That's my excuse for the gaps in my knowledge.)

I've been using python since the 90s, and I learned a few things from this post.
Right after this string of replies, I was expecting Guido van Rossum would be next, saying he created Python and even he learnt something new...
> ... I wasn't aware of named slices for some reason ....

I wasn't either. But I wouldn't call them a hidden feature of the language. A slice object is an object. So you can make it the value of a named variable, just like any other object. Somehow that wasn't obvious, though.

Now I'm wondering how else I might be able to improve my code by giving names to non-obvious things.

Same here, learned something new today.
A common theme running through named tuples, itertools and collections is Raymond Hettinger. He has also put together lots of tutorials and talks.
Great suggestion. Just searched for him on youtube and a couple of excellent looking talks popped up. Halfway through and this one seems great so far: https://www.youtube.com/watch?v=OSGv2VnC0go

Really enjoy his style as well :)

Thank you sir, something else to go through on a quiet Sunday :).