[Python-ideas] Augmented assignment syntax for objects.
Paul Moore
p.f.moore at gmail.com
Tue Apr 25 18:09:10 EDT 2017
On 25 April 2017 at 22:27, Mike Miller <python-ideas at mgmiller.net> 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 a pull request if it's open source.
>> Such
>> a macro would generate automatically those long-to-write lines, and maybe
>> implement some code folding if vertical space is an issue.
>
>
> I'm personally not bothered by vertical space, but rather typing the same
> thing three times with self's and ='s. That's more boilerplate than Java.
> ;)
Well,
class MyClass:
@auto_args
def __init__(self, a, b, c=None):
pass
seems ideal for you then (using the auto_args decorator from
https://twitter.com/judy2k/status/854330478068977664 - a 13-line
function including the import of inspect and some comments).
(Arguing for auto_args to be in the stdlib may be a better option than
arguing for new syntax, BTW...)
Paul
More information about the Python-ideas
mailing list