I have a list of numbers. For example,
idList = [78,24,67,43]
from which I wish to create a dictionary of tuples like so:
files = {('file', open(78, 'rb)), ('file', open(24, 'rb)), ('file', open(67, 'rb)), ('file', open(43, 'rb))}
How can I do this?
I currently do it like this:
for each in idList:
listofTuples.append(('file', open(str(each) + '.pdf', 'rb')))
print(dict(listofTuples))
However, this will produce a dictionary containing only 1 tuple.
Edit: I am doing this so I can upload multiple files to a website in a single request. For example, see this answer.