[Python-ideas] Augmented assignment syntax for objects.

Erik python at lucidity.plus.com
Wed Apr 26 18:29:19 EDT 2017


On 26/04/17 19:15, Mike Miller wrote:
> As the new syntax ideas piggyback on existing syntax, it doesn't feel
> like that its a complete impossibility to have this solved.  Could be
> another "fixed papercut" to drive Py3 adoption.  Taken individually not
> a big deal but they add up.

*sigh* OK, this has occurred to me over the last couple of days but I 
didn't want to suggest it as I didn't want the discussion to fragment 
even more.

But, if we're going to bikeshed and there is some weight behind the idea 
that this "papercut" should be addressed, then given my previous 
comparisons with importing, what about having 'import' as an operator:

def __init__(self, a, b, c):
    self import a, b
    self.foo = c * 100

Also allows renaming:

def __init__(self, a, b, c):
    self import a, b, c as _c

Because people are conditioned to think the comma-separated values after 
"import" are not tuples, perhaps the use of import as an operator rides 
on that wave ...

(I do realise that blurring the lines between statements and operators 
like this is probably not going to work for technical reasons (and it 
just doesn't quite read correctly anyway), but now we're bikeshedding 
and who knows what someone else might come up with in response ...).

E.


More information about the Python-ideas mailing list