On Fri, Mar 23, 2018 at 11:25 AM, Antoine Pitrou <solip...@pitrou.net> wrote: > On Fri, 23 Mar 2018 07:25:33 +0100 > Jeroen Demeyer <j.deme...@ugent.be> wrote: > >> On 2018-03-23 00:36, Antoine Pitrou wrote: >> > It does make sense, since the proposal sounds ambitious (and perhaps >> > impossible without breaking compatibility). >> >> Well, *some* breakage of backwards compatibility will be unavoidable. >> >> >> My plan (just a plan for now!) is to preserve backwards compatibility in >> the following ways: >> >> * Existing Python attributes of functions/methods should continue to >> exist and behave the same >> >> * The inspect module should give the same results as now (by changing >> the implementation of some of the functions in inspect to match the new >> classes) >> >> * Everything from the documented Python/C API. >> >> >> This means that I might break compatibility in the following ways: >> >> * Changing the classes of functions/methods (this is the whole point of >> this PEP). So anything involving isinstance() checks might break. >> >> * The undocumented parts of the Python/C API, in particular the C structure. > > 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. Thanks, E _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/