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 <greg.ew...@canterbury.ac.nz> wrote: > Sorry if this has already been answered, but if it has I missed it. > > From your demo: > > class HistoricVar: > > def __getself__(self): > return self.var > > What stops the reference to 'self' here from invoking __getself__ again? > > -- > Greg > _______________________________________________ > 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/A43QPHRQ4CWMSZ4AJ2E5RCCQE3V4OG5L/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Nate Lust, PhD. Astrophysics Dept. Princeton University
_______________________________________________ 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/RUPYJKBQGKIPWQVP2CJWJR75IAPURW25/ Code of Conduct: http://python.org/psf/codeofconduct/