4 ms·
As someone who's bounced back and forth between Python 2 and Python 3, I'm curious about your need of parameter tuple unpacking[0]. I've never encountered it, a
by lelandbatey 11y ago
As someone who's bounced back and forth between Python 2 and Python 3, I'm curious about your need of parameter tuple unpacking[0]. I've never encountered it, and after some research I don't understand the use case.
I don't mean to sound like I'm trying to belittle your position, I would like to understand more. The PEP below doesn't seem to do a very good job explaining why people like them, and I'd like to hear a proponents position on the feature.
[0] - https://www.python.org/dev/peps/pep-3113/ https://www.python.org/dev/peps/pep-3113/
- unoti 11y agoA good example of a use case I can think of would be to pass an (x,y) coordinate pair as a single parameter, and unpack it in the parameter definition. This would save having an extra line that says (x,y) = pt. Unless I'm missing something, I don't see this as a show stopper personally, and see it as increasing readability.
- jacobolus 11y agoYou should use a namedtuple for that sort of thing, and then refer to the members as pt.x and pt.y.
- mycelium 11y agoI use it like es6 or haskell destructuring. Sure it's a little weak compared to both those implementations, but the tuple case covers enough to be useful.
- pyre 11y agoEC6 allows you to destructure in the function definition?
- mycelium 11y agoYep. It's awesome. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Function_argument_defaults https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- emidln 11y agoAs someone who splits his time between Python, Clojure, and Javascript (via Babel), lack of this is extremely annoying for Python since the other two languages allow it.
- wfunction 11y ago> As someone who's bounced back and forth between Python 2 and Python 3, I'm curious about your need of parameter tuple unpacking[0]. I've never encountered it, and after some research I don't understand the use case. > I don't mean to sound like I'm trying to belittle your position, I would like to understand more. The PEP below doesn't seem to do a very good job explaining why people like them, and I'd like to hear a proponents position on the feature. Basically, I need it for functional programming. See here: https://news.ycombinator.com/item?id=10213963 https://news.ycombinator.com/item?id=10213963