Is there a better way to do this? I feel like I am doing something wrong by being too repetitive.
O = viz.pick(1, viz.WORLD)
BackSetts = ["set_b1b", "set_b2a", "set_b1a", "set_b2b"]
LeftSetts = ["set_l1a", "set_l1b", "set_l2a", "set_l1b"]
NormSetts = ["set_nr_a", "set_nr_b"]
Maps = ["MapA","MapB"]
if O.name in BackSetts:
for i in set(BackSetts)|set(Maps):
WORLD[i].alpha(abs(WORLD[i].getAlpha()-1))
elif O.name in LeftSetts:
for i in set(LeftSetts)|set(Maps):
WORLD[i].alpha(abs(WORLD[i].getAlpha()-1))
elif O.name in NormSetts:
for i in NormSetts:
WORLD[i].alpha(abs(WORLD[i].getAlpha()-1))
One way to rephrase for clarity is to read the sentence once and then set it aside and determine what you're trying to say to your specific audience. Paraphrasing refers to taking what someone else said or wrote and rephrasing it using different words.
The trivial transformation is:
O = viz.pick(1, viz.WORLD)
BackSetts = ["set_b1b", "set_b2a", "set_b1a", "set_b2b"]
LeftSetts = ["set_l1a", "set_l1b", "set_l2a", "set_l1b"]
NormSetts = ["set_nr_a", "set_nr_b"]
Maps = ["MapA","MapB"]
anyset = []
if O.name in BackSetts:
anyset = set(BackSetts)|set(Maps)
elif O.name in LeftSetts:
anyset = set(LeftSetts)|set(Maps)
elif O.name in NormSetts:
anyset = NormSetts
for i in anyset:
WORLD[i].alpha(abs(WORLD[i].getAlpha()-1))
This takes care such that NormSetts is not union'd with Maps, as in your original code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With