
On Mon, May 2, 2022 at 7:21 AM Steven D'Aprano <steve@pearwood.info> wrote:
On Sun, May 01, 2022 at 06:22:08PM -0700, Devin Jeanpierre wrote:
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
What would this do?
def __init__(self, spam.x, eggs.y): pass
Would it try to assign to variables spam and eggs in the surrounding scopes?
How about this?
def __init__(self, x, x.y): pass
Yes, I agree. I don't think that the syntax is unreasonable, but it looks like it would be putting `self` at the same "level" of all the other possible parameters and could lead to this kind of confusion. What _might_ be a possibility (I'm not advocating in favor of it) is, like ruby does, to also add the `@x` as syntactic sugar for `self.x` in the body of the methods. This way the `@x` in the signature would be consistent, but I believe it can conflict conceptually with the "explicit self" philosophy.
-- Steve _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@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/WDRZ7Q... Code of Conduct: http://python.org/psf/codeofconduct/