I have a function that defines two lists, and I'd like to refer to one of these lists based on the variable passed as an argument. Note that I cannot pass the list as an argument since the list doesn't exist yet.
Is it simple to do in python? or I should create the lists outside and pass them as arguments for the sake of simplicity
def move(self,to_send):
photos = ['example1']
videos = ['example2']
for file in @to_send: #where @to_send is either 'photos' or 'movies'
...
if whatever:
move('photos')
else:
move('videos')
EDIT: In order to avoid eval to transform the string into a list, I could do
def move(self,to_send):
photos = ['example1']
videos = ['example2']
if to_send == 'photos':
to_send = photos
else:
to_send = videos
for file in to_send:
...