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

2017-04-28 Thread Erik
On 28/04/17 10:47, Paul Moore wrote: On 28 April 2017 at 00:18, Erik wrote: The semantics are very different and there's little or no connection between importing a module and setting an attribute on self. At the technical level of what goes on under the covers,

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

2017-04-28 Thread Paul Moore
On 28 April 2017 at 14:07, Nick Coghlan wrote: >> Am I missing some point? > > Yes, the point I attempted to raise earlier: at the language design > level, "How do we make __init__ methods easier to write?" is the > *wrong question* to be asking. It's treating the symptom

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

2017-04-28 Thread Chris Angelico
On Sat, Apr 29, 2017 at 1:31 AM, Steven D'Aprano wrote: > On Fri, Apr 28, 2017 at 05:23:59PM +1000, Chris Angelico wrote: > __init__ is called, the argument 42 is bound to the formal parameter > "attr", the assignment self.attr = attr is run, and THEN the body of the > method

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

2017-04-28 Thread Stephan Hoyer
On Fri, Apr 28, 2017 at 4:55 AM, Tin Tvrtković wrote: > I'm going to posit we need declarative classes. (This is what a library > like attrs provides, basically.) For a class to be declarative, it needs to > be possible to inspect the class for its attributes and more. > >

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

2017-04-28 Thread Steven D'Aprano
On Fri, Apr 28, 2017 at 05:23:59PM +1000, Chris Angelico wrote: > Waait a minute. Since when is the *declaration* doing this? That's what the suggested syntax says. You put the attribute assignment you want in the parameter list, which is part of the function/method declaration, not the

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

2017-04-28 Thread Nick Coghlan
On 28 April 2017 at 22:26, Paul Moore wrote: > On 28 April 2017 at 12:55, Tin Tvrtković wrote: >> I'm putting forward three examples. These examples are based on attrs since >> that's what I consider to be the best way of having declarative classes in

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

2017-04-28 Thread Nick Coghlan
On 28 April 2017 at 21:55, Tin Tvrtković wrote: > Third example: I work at a mobile games company. The backends are Python, > the games are written in other languages. The backends and the games share > data structures - requests, responses, the save game, game data. I want

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

2017-04-28 Thread Paul Moore
On 28 April 2017 at 12:55, Tin Tvrtković wrote: > I'm putting forward three examples. These examples are based on attrs since > that's what I consider to be the best way of having declarative classes in > Python today. Your comments and examples are interesting, but don't

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

2017-04-28 Thread Tin Tvrtković
I'm gonna take a shot at elaborating this point. We Python programmers often tout Python as a high-level, high-productivity language where complex and useful things are easy to do. However, vanilla Python classes are anything but high level; they're basically glorified dictionaries that require

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

2017-04-28 Thread Steven D'Aprano
On Fri, Apr 28, 2017 at 03:30:29PM +1000, Chris Angelico wrote: > > Obviously we can define syntax to do anything we like, but what is the > > logical connection between the syntax and the semantics? What part of > > "function parameter list" suggests "assign attributes to arbitrary > > objects"?