[Python-ideas] Augmented assignment syntax for objects.

Erik python at lucidity.plus.com
Thu Apr 27 19:18:19 EDT 2017


On 27/04/17 23:43, Steven D'Aprano wrote:
> On Wed, Apr 26, 2017 at 11:29:19PM +0100, Erik wrote:
>> def __init__(self, a, b, c):
>>    self import a, b
>>    self.foo = c * 100
>
> [snarky]
> If we're going to randomly choose arbitrary keywords with no connection
> to the operation being performed,

The keyword I chose was not random or arbitrary and it _does_ have a 
connection to the operation being performed (bind a value in the source 
namespace to the target namespace using the same name it had in the 
source namespace - or rename it using the 'as' keyword).

> can we use `del` instead of `import`
> because it's three characters less typing?

Comments like this just serve to dismiss or trivialize the discussion. 
We acknowledged that we're bikeshedding so it was not a serious 
suggestion, just a "synapse prodder" ...

> But seriously, I hate this idea.

Good. It's not a proposal, but something that was supposed to generate 
constructive discussion.

> 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, yes. At the 
higher level of what the words mean in spoken English, it's really not 
so different a concept.

> If we're going to discuss pie-in-the-sky suggestions,

That is just dismissing/trivializing the conversation again.

> (If you don't like "inject", I'm okay with "load" or even "push".)

No you're not, because that's a new keyword which might break existing 
code and that is even harder to justify than re-using an existing 
keyword in a different context.

> the problem this solves isn't big or
> important enough for the disruption of adding a new keyword.

So far, you are the only one to have suggested adding a new keyword, I 
think ;)

E.


More information about the Python-ideas mailing list