Can you have GS and crop at the same time and if so are you expecting a -crop-GS_xcf result?
Are GS and crop booleans?
Lambdas not a solution here. To avoid ifs your best weapon is an array or dictionary of postfixes, keyed by the option.
Something I sometimes do with booleans is take advantage of the fact that they are automatically converted to 0 or 1, so you can write things like:
Otherwise your code is also a backwards walking mammoth, I would have used:
Or using %-formatting and my boolean-indexed array trick
Other people would build a list of name parts and use
Are GS and crop booleans?
Lambdas not a solution here. To avoid ifs your best weapon is an array or dictionary of postfixes, keyed by the option.
Something I sometimes do with booleans is take advantage of the fact that they are automatically converted to 0 or 1, so you can write things like:
Code:
value=[valueIfFalse,ValueIfTrue][boolean]
Otherwise your code is also a backwards walking mammoth, I would have used:
Code:
theName=name
if GS: theName+='-GS'
if crop: theName+='-crop'
theName+=postFix
Or using %-formatting and my boolean-indexed array trick
Code:
theName='%s%s%s_xcf.webp' % (name, ['','-crop'][crop],['','-GS'][GS])
Other people would build a list of name parts and use
Code:
theName=''.join(nameParts)