Decorator to avoid a mistake
23 Nov
2016
23 Nov
'16
5:07 a.m.
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
2697
Age (days ago)
2705
Last active (days ago)
28 comments
14 participants
participants (14)
-
Adrián Orive Oneca
-
Chris Barker
-
fleblanc50
-
France3
-
François Leblanc
-
Guido van Rossum
-
Nick Coghlan
-
Nick Timkovich
-
Paul Moore
-
Sebastian Kreft
-
Stephen J. Turnbull
-
Steven D'Aprano
-
Victor Stinner
-
Vince Vinet