In a function like the following:
def foo(case):
if case == 1:
my_var = []
# then do something with my_var
elif case == 2:
my_var = {}
# then do something with my_var
Since the variable my_var
lives in different cases, so it shouldn't cause a problem at runtime. But is this a good practice in Python?