I have a global variable ser
which I need to delete under certain circumstances:
global ser
ser = ['some', 'stuff']
def reset_ser():
print('deleting serial configuration...')
del ser
If I call reset_ser()
I get the error:
UnboundLocalError: local variable 'ser' referenced before assignment
If I give the global variable to the function as an input I do not get the error, but the variable does not get deleted (I guess only inside the function itself). Is there a way of deleting the variable, or do I e.g.have to overwrite it to get rid of its contents?