[issue28776] Duplicate method names should be an error

2016-11-22 Thread Peter Inglesby
Peter Inglesby added the comment: OK, I'll defer to your collective decades of experience and wisdom! Thanks for all you all do for Python. -- ___ Python tracker

[issue28776] Duplicate method names should be an error

2016-11-22 Thread R. David Murray
R. David Murray added the comment: It isn't ignored. The first definition is entered into the class dictionary, then the second definition replaces it. That's why Victor talked about redefining a method, because that's what happens. You can't really disentangle the two cases except by

[issue28776] Duplicate method names should be an error

2016-11-22 Thread Peter Inglesby
Peter Inglesby added the comment: Victor, I'm not talking about redefining a method, and David, I don't think I'm talking about changing dynamic nature of the class dictionary. All I'm suggesting is that if some code contains a class whose body defines the same method twice, Python should

[issue28776] Duplicate method names should be an error

2016-11-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Yes, IMO this is something that needs to go into a linter, > not Python itself. I concur with David Murray. This would break too many classes and is at odds with the design of Python where code inside a class definition is executed in its own namespace

[issue28776] Duplicate method names should be an error

2016-11-22 Thread R. David Murray
R. David Murray added the comment: Yes, IMO this is something that needs to go into a linter, not Python itself. The dynamic nature of the class dictionary is too important to many programs to change it at this point. -- nosy: +r.david.murray ___

[issue28776] Duplicate method names should be an error

2016-11-22 Thread STINNER Victor
STINNER Victor added the comment: Without modifying the language, I guess that it's already technically possible to implement that in Python 3 in an application. Using the __prepare__() method of a metaclass and a custom dict subclass, I think that you can build what you want. I mean that you

[issue28776] Duplicate method names should be an error

2016-11-22 Thread STINNER Victor
STINNER Victor added the comment: Redefine a method is a common practice indirectly using decorators: @staticmethod def method(): pass is like: def method(): pass method = staticmethod(method) So you can clarify what do you mean by "redefining"? Some linters already can such common

[issue28776] Duplicate method names should be an error

2016-11-22 Thread Peter Inglesby
New submission from Peter Inglesby: It should be an error for a class to define a method twice. That is, Python should raise an exception when the following code is loaded: class C: def m(self): # do something def m(self): # do something I have just witnessed a