On 2017-05-14 00:34, Chris Angelico wrote:
On Sun, May 14, 2017 at 2:53 PM, Brendan Barnwell <brenb...@brenbarn.net> wrote:
        Attributes aren't just for passing things to other methods.  They're
for storing state.  In your proposed system, how would an object mutate one
of its own attributes?  It looks like "x" here is just stored in a function
closure, which wouldn't allow easy mutation.  Also, how would another object
access the attribute from outside (as we currently do with self.x)?  You can
say we'd only use this new attribute-free approach when we want to pass a
constructor argument that's used but never mutated or accessed from outside,
but that severely restricts the potential use cases, and all it saves you is
typing "self".

My expectation is that you'd be using "nonlocal x" to do that.

That would allow mutation from within methods, but (as far as I can tell) not access (or mutation) from outside the class.

--
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail."
   --author unknown
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to