Phase 8 — async / await
Phase 8 — async / await
Goals for this phase, and a JS/TS → Python cheat sheet
Estimated time: ~45 minutes. ⭐⭐⭐ — the last thing for today.
You already know this concept from JS — Python's version uses almost identical keywords.
Goals
async def get_user():
data = await fetch_data()
return dataUnderstand:
def— a normal functionasync def— an asynchronous functionawait— wait for an async operation to finish
That's genuinely enough for tomorrow — one more page on this, and you're done for today.
Cheat sheet
JavaScript / TypeScript Python
───────────────────────────────────────────────────────
function getUser() { } def get_user():
async function getUser() { async def get_user():
const data = await fetchData(); data = await fetch_data()
return data; return data
}
await getUser() await get_user() (only inside an async def)