Mark Dickinson added the comment:
Sorry, I'm closing this as rejected. It might possibly have been better to
write the code this way to begin with, but the code is already there, it's
working, and there's little to be gained by 'fixing' it at this point.
--
assignee: -> mark.dickins
Éric Araujo added the comment:
Thanks for the report. If I may offer recommendations about submitting bugs:
- Know that stable branches don’t get code cleanups, only bug fixes, so you
have to target 3.3
- Focused bugs (“code duplication in packaging commands”) are much better that
over-broad
skreft added the comment:
One possible refactor would be.
import operator
def logical_or(self, other, context=None):
return self._logical_op(other, operator.__or__, context)
def logical_xor(self, other, context=None):
return self._logical_op(other, operator.__xor__, contex
Mark Dickinson added the comment:
How would you suggest refactoring this?
For that example, I'd prefer not to remove the repetition; as it is, the code
is clean and clear. Eliminating the repetition would involve adding an extra
layer of indirection, making the code in one of these function
New submission from skreft :
By using tools like clonedigger is possible to spot some repeated code.
One file that caught my attention is Lib/decimal.py. It has many portions of
duplicated code.
Here is an example:
def logical_or(self, other, context=None):
"""Applies an 'or' operation