Hi there,

I like python easy extend class and reusse code, but sometime I overwrite 
involontary some functions or variables from parents.
I think about a decorator to confirm overwrite is intended and put a warning if 
is not present.
 
 class A:
   def hello(self):
      print('Hello A')

 class B:
   def hello(self):
      print('Hello B')

  class C:
    @overwrite
      def hello(self):
       print('Hello C')


b=B()
c=C()

b.hello()
Warning overwrite hello method...
Hello B

c.hello()
Hello C

Dont know if this should be add to language this way or another, or if this 
should be in pylint only ...

Perhaps someone get better way to achieve this or something already exist?


May the python be with you,

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