Sometimes we want to write a snippet which acts only if a variable doesn’t existThis one is fairly straightforward to do using the globals function:
if 'varname' not in globals(): varname = 'Here now!' # do stuff else: print varname
I wonder if there’s a better way?