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?

ChrisA
_______________________________________________
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