Devin Jeanpierre writes:

 > Is it unreasonable to instead suggest generalizing the assignment target
 > for parameters? For example, if parameter assignment happened left to
 > right, and allowed more than just variables, then one could do:
 > 
 > def __init__(self, self.x, self.y): pass

At a glance, this is the most attractive syntax I've seen for this.
If you're a keystroke minimizer, you can't do quite as well as

def __init__(self, @x, @y): pass

but

def __init__(s, s.x, s.y): pass

isn't bad at all.


 > 
 > Python 2 had non-variable parameters (but not attributes, just unpacking:
 > def foo((x, y)): pass), but it was removed in Python 3, because of issues
 > with introspection (among other, perhaps less significant, issues):
 > https://peps.python.org/pep-3113/
 > 
 > Perhaps now that positional-only parameters exist, and the introspection
 > APIs have evolved over time, there is a way to work this into the
 > introspection APIs sensibly.
 > 
 > (a "@foo" parameter does not have this problem, because it's just a
 > parameter named `foo` with some extra stuff.)
 > 
 > -- Devin
 > _______________________________________________
 > Python-ideas mailing list -- python-ideas@python.org
 > To unsubscribe send an email to python-ideas-le...@python.org
 > https://mail.python.org/mailman3/lists/python-ideas.python.org/
 > Message archived at 
 > https://mail.python.org/archives/list/python-ideas@python.org/message/UY2TQTPRFAPN3OG3TBPCOYMAYZWFZ3E4/
 > Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/KBWASQWSLY2TAOTU6KKJI433SGOFM2JX/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to