I want to ask you your different points of view for the following scenario: imagine that we have several lists and something should be executed for those that are not empty:
if l1 or l2 or l3 or l4 or l5 or l6 or l7 or l8 or l9:
print 'we have to do something in one or more lists'
if l1:
print 'l1'
f1()
if l2:
print 'l2'
f2()
if l3:
print 'l3'
f3()
if l4:
print 'l4'
f4()
if l5:
print 'l5'
f5()
if l6:
print 'l6'
f6()
if l7:
print 'l7'
f7()
if l8:
print 'l8'
f8()
if l9:
print 'l9'
f9()
The code itself its is simple and understandable but this throws a (12) value for Mccabe complexity. To reduce this value, how would you approach it? I am very open an interested in hearing your thoughts.
Thank you in advance.
UPDATE:
Imagine exactly this concrete situation. How could you approach it?:
if a:
A = True
if b:
B = True
if c:
C = True
if d:
D = "D"
if e:
E = "E"
if f:
F = "F"
I think that, in this case, creating 6 different functions its not efficient and pythonic...