I am currently bringing a list down from an api and changing the names based on severity levels
Right now my code to do this is
priname = list((item['fields']['priority']['name']) for item in data['issues'])
priname = [w.replace('Trivial', 'Low')
.replace('Minor', 'Low')
.replace('Moderate', 'Medium')
.replace('Major', 'High')
.replace('Critical', 'High')
.replace('Blocker', 'Emergency')for w in priname]
So I am just replacing strings in the list to keywords that generalize the content. When I do this to larger lists, it takes forever to return the altered list which i realize means this is not an efficient way of doing this at all.
Can anyone point me in a direction where i can streamline this find and replace?
EDIT:
Priname=[
'Critical',
'Moderate',
'Major',
'Moderate',
'Moderate',
'Critical',
'Moderate',
'Moderate',
'Moderate',
'Blocker',
'Critical',
'Moderate',
'Moderate',
'Major',
'Moderate',
'Critical'
]
[... for x in ...]) rather thanlist()+ generator-expression. It's more Pythonic.dataorprinameso we can see what we're working with?Prinamecan have two replacements applied to it, or is it strictly one replacment operation (at most) per element?