In Typescript I'm used to writing async code like this:
async function foo() // returns a promise
return new Promise<string>( resolve, reject) {
resolve('Hello!');
});
async function bar() {
s: string = await foo();
}
async function baz() {
foo().then((s: string) { alert(s); }
How would I go about doing this in python (>= 3.7.0)? I guess this is correct:
async def bar:
await s = foo()
But what about the python equivalents for foo() and baz()? How would I write them? Should I be using concurrent.futures.Future objects? If so, how?