Neutral ATL transform aka Identity transform (to use as default argument)
Posted: Sun Dec 24, 2023 12:49 pm
I'm passing an ATL transform to a parameter label so I can customise the way I display a BG image:
However, I noticed that my default value of None causes an error:
This doesn't seem to be defined natively, which means I need to define my own dummy transform that does nothing:
and use it as default value.
Or, in order to support both passing a transform and no transform, create two cases:
which is more verbose.
UPDATE: tested both methods, they do work
Code: Select all
label show_bg(bg_name, tr=None):
show expression "bg " + bg_name at tr
So, the most logical would be to pass a "neutral" or "identity" transform that does nothing, when I want to show the BG as such.TypeError: 'NoneType' object is not callable
This doesn't seem to be defined natively, which means I need to define my own dummy transform that does nothing:
Code: Select all
transform identity:
pass
Or, in order to support both passing a transform and no transform, create two cases:
Code: Select all
label show_bg(bg_name, tr=None):
if tr:
show expression "bg " + bg_name at tr
else:
show expression "bg " + bg_name
UPDATE: tested both methods, they do work