28.03.18 20:22, Erik Bray пише:
On Fri, Mar 23, 2018 at 11:25 AM, Antoine Pitrou <solip...@pitrou.net> wrote:
One breaking change would be to add __get__ to C functions. This means
e.g. the following:
class MyClass:
my_open = open
would make my_open a MyClass method, therefore you would need to spell
it:
class MyClass:
my_open = staticmethod(open)
... if you wanted MyClass().my_open('some file') to continue to work.
Of course that might be considered a minor annoyance.
I don't really see your point in this example. For one: why would
anyone do this? Is this based on a real example? 2) That's how any
function works. If you put some arbitrary function in a class body,
and it's not able to accept an instance of that class as its first
argument, then it will always be broken unless you make it a
staticmethod. I don't see how there should be any difference there if
the function were implemented in Python or in C.
Yes, there are real examples. Good or bad, it is well known behavior of
builtin functions, and real code depends on it. For sure changing it
will break a lot of user code (and also the Python stdlib and tests).
Just try to implements the support of the descriptor protocol in builtin
functions and you will see how much code this will break.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/