On 06/19/2017 06:31 PM, Chris Angelico wrote:
On Tue, Jun 20, 2017 at 10:18 AM, Steven D'Aprano <st...@pearwood.info> wrote:
Having said that, there's another problem: adding this feature (whatever
it actually is) to __getattr__ will break every existing class that uses
__getattr__. The problem is that everyone who writes a __getattr__
method writes it like this:
def __getattr__(self, name):
not:
def __getattr__(self, name, error):
so the class will break when the method receives two arguments
(excluding self) but only has one parameter.
Why not just write cross-version-compatible code as
def __getattr__(self, name, error=None):
? Is there something special about getattr?
The point was existing code would fail until that change was made. And a lot
of existing code uses __getattr__.
--
~Ethan~
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/