Is is possible to create multiple variables in an async with
statement ?
I know that the equivalent synchronous version exists from here: Multiple variables in a 'with' statement?
so the synchronous version looks like this:
# some files
f1 = 'tests/test_csv.csv'
f2 = 'tests/some_file.txt'
f3 = ''
with open(f1) as a, open(f2) as b:
contents_1 = a.readlines()
contents_2 = b.readlines()
print('this is contents 1:')
print(contents_1)
print('this is contents 2:')
print(contents_2)
And this works nicely.
But will the same extend to the async
version in a similar way ?
for example like this:
async with A() as a, B() as b:
while True:
result_1 = await a.A()
result_2 = await b.B()
if (result_1):
print(result_1)
if (result_2):
print(result_2)
would the above work or, if not, how could one make this work?