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...
Re:Python Language Features and Tricks
by ggchappell on Sunday March 09, 2014 @09:04PM
(#7370749)
> ... 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.
Re:Python Language Features and Tricks
by maxerickson on Saturday March 08, 2014 @06:13PM
(#7366780)
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 :)
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)