Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Juancarlo Añez
On Tue, Apr 25, 2017 at 6:09 PM, Paul Moore wrote: > (Arguing for auto_args to be in the stdlib may be a better option than > arguing for new syntax, BTW...) > Having such a decorator in the stdlib would allow IDEs and syntax highlighters to know what's going on. -- Juancarlo *Añez* _

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Nathaniel Smith
On Tue, Apr 25, 2017 at 3:30 PM, Erik wrote: > On 25/04/17 23:05, Paul Moore wrote: >> >> 1. Writing out the assignments "longhand" is an unacceptable burden. > > > There are reasons why augmented assignment was implemented. One of them was > to make the code easier to read: > > foil = foil + 1

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Chris Angelico
On Wed, Apr 26, 2017 at 10:05 AM, Ryan Gonzalez wrote: > FWIW I always liked > Dart's/Ruby's/Crystal's/(Coffee|Moon)Script's/WhateverElse's style: > > > class Cls { > Cls(this.a); // IT'S MAGIC > } > > > but the Python equivalent is admittedly weirder: > > > def ___init__(self, self.attr): In

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Ryan Gonzalez
FWIW I always liked Dart's/Ruby's/Crystal's/(Coffee|Moon)Script's/WhateverElse's style: class Cls { Cls(this.a); // IT'S MAGIC } but the Python equivalent is admittedly weirder: def ___init__(self, self.attr): partly because, it'd have to work on pretty much any other variable name, yet

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Matt Gilson
On Tue, Apr 25, 2017 at 4:31 PM, Erik wrote: > On 25/04/17 22:15, Brice PARENT wrote: > >> it may be easier to get something like this >> (I think, as there is no new operator involved) : >> > > No new operator, but still a syntax change, so that doesn't help from that > POV. > > >> def __init__(

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Erik
On 25/04/17 22:15, Brice PARENT wrote: it may be easier to get something like this (I think, as there is no new operator involved) : No new operator, but still a syntax change, so that doesn't help from that POV. def __init__(self, *args, **kwargs): self.* = *args self.** = **k

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Erik
On 25/04/17 23:05, Paul Moore wrote: 1. Writing out the assignments "longhand" is an unacceptable burden. There are reasons why augmented assignment was implemented. One of them was to make the code easier to read: foil = foil + 1 foil = foi1 + 1 foil += 1 Should one be silly enough t

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Erik
On 25/04/17 02:15, Chris Angelico wrote: Bikeshedding: Your example looks a lot more like tuple assignment than multiple assignment. Well, originally, I thought it was just the spelling-the-same-name-twice thing that irritated me and I was just going to suggest a single assignment version lik

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Paul Moore
On 25 April 2017 at 22:27, Mike Miller wrote: > On 2017-04-25 14:15, Brice PARENT wrote: >> >> But, any of these proposals, mine and yours, if you really need this to >> shorten >> the code writing time or vertical space only, is not a better idea than to >> propose a macro to your IDE editor, or

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Paul Moore
On 25 April 2017 at 22:15, Brice PARENT wrote: >> Also, I did find the decorator proposal intriguing, though have to say I >> probably wouldn't bother to use it unless it were a builtin or I had a dozen >> parameters to deal with. >> > If you *need* a shorter solution, even though I'm not entirely

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Mike Miller
On 2017-04-25 14:15, Brice PARENT wrote: But, any of these proposals, mine and yours, if you really need this to shorten the code writing time or vertical space only, is not a better idea than to propose a macro to your IDE editor, or a pull request if it's open source. Such a macro would gener

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Sven R. Kunze
On 25.04.2017 20:16, Mike Miller wrote: Also, I did find the decorator proposal intriguing, though have to say I probably wouldn't bother to use it unless it were a builtin or I had a dozen parameters to deal with. Same here. And practical experience tells me that the usage of this decorator

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Mike Miller
Agreed with Steven, although I do find myself a little more annoyed and bothered by a typical init than him I guess. Even so I didn't think the current proposals went far enough. To tilt the balance farther, to make it easier, let's go all the way! Instead of continuing duplication: >>> d

Re: [Python-ideas] Binary arithmetic does not always call subclasses first

2017-04-25 Thread Guido van Rossum
Now that I am with a real keyboard and screen and have tried to understand the OP, I can actually write up my thoughts on the matter. There are two aspects to the behavior. Giving preference to the class of the right operand if it is a subclass of the left operand's class is reasonable and explain

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Tin Tvrtković
You might want to check out attrs (http://attrs.readthedocs.io/en/stable/). It can generate the __init__ for you, and much much more. Date: Tue, 25 Apr 2017 14:33:49 +0200 > From: George Fischhof > To: Paul Moore > Cc: Python-Ideas , "Steven D'Aprano" > > Subject: Re: [Python-ideas] Au

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread George Fischhof
2017. ápr. 25. de. 10:04 ezt írta ("Paul Moore" ): On 25 April 2017 at 03:53, Steven D'Aprano wrote: > On Tue, Apr 25, 2017 at 02:08:05AM +0100, Erik wrote: > >> I often find myself writing __init__ methods of the form: >> >> def __init__(self, foo, bar, baz, spam, ham): >> self.foo = foo >>

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Daniel Moisset
I actually saw a decorator like that last week, https://twitter.com/judy2k/status/854330478068977664 On 25 April 2017 at 08:56, Paul Moore wrote: > On 25 April 2017 at 03:53, Steven D'Aprano wrote: > > On Tue, Apr 25, 2017 at 02:08:05AM +0100, Erik wrote: > > > >> I often find myself writing __

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Paul Moore
On 25 April 2017 at 03:53, Steven D'Aprano wrote: > On Tue, Apr 25, 2017 at 02:08:05AM +0100, Erik wrote: > >> I often find myself writing __init__ methods of the form: >> >> def __init__(self, foo, bar, baz, spam, ham): >> self.foo = foo >> self.bar = bar >> self.baz = baz >> self.spam =