At my internship I have noticed that another coworker of mine has manipulated one of my functions from doing this...
if isSinglesMatch:
name1 = GetName(1, “BUG”)
name2 = GetName(2, "BUG")
else:
name1 = GetName(1, "Short")
name2 = GetName(2, "Short")
to this...
name1 = GetName(1, "BUG" if isSinglesMatch else "Short")
name2 = GetName(2, "BUG" if isSinglesMatch else "Short")
I see that his code is shorter, but is there any advantage like it being interpreted faster? Is it bad to keep it the way I had it in the first place, because in my opinion it is easier to debug my code (there are a few extra variable assignments that I left out of this example).
No one at my internship has told me that I should change the way I do things, I just noticed that this is the way my coworker likes to do it.
Aucun commentaire:
Enregistrer un commentaire