This is one of the exception cases in my proposal, variables used inside their own methods don't have __getself__ called when they are loaded.
The proposal basically reads: class instances that are looked up with a named variable will have __getself__ invoked when the interpreter loads them, except when they are used within their own methods, or when used as an argument to/from a function.
That second part about functions was not part of the original proposal, but is something I am currently exploring to address some questions others have raised. I have not fully thought about what the consequences would be, and it may or may not stick around in the long term. I feel quite strongly about the first exception however, as it makes writing a class body manageable, without over burdening the author to put special escape functions all over the place.
On Thu, Jun 27, 2019 at 7:42 PM Greg Ewing firstname.lastname@example.org wrote:
Sorry if this has already been answered, but if it has I missed it.
From your demo:
def __getself__(self): return self.var
What stops the reference to 'self' here from invoking __getself__ again?
Python-ideas mailing list -- email@example.com To unsubscribe send an email to firstname.lastname@example.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://email@example.com/message/A43QPH... Code of Conduct: http://python.org/psf/codeofconduct/
-- Nate Lust, PhD. Astrophysics Dept. Princeton University