Python for Luau Developers
Move from Luau tables, type annotations and metatables to Python collections and classes. Compare truthiness, indexing, multiple returns, closures, exceptions and module loading, then build a connected order processor.
Luau and Python side by side
The same program in Luau and in Python, from the lessons of this course.
Printing and Text
Luau print separates its arguments with tabs; Python print uses spaces unless configured otherwise. Luau strings hold bytes, while Python str holds Unicode text. Use # for Python comments and + for string concatenation instead of -- and ... Python f-strings…
Luau1-- Readable status2print("Status:", "ready")3print("Don't stop")Python1# A comment for readers2print("Status:", "ready")3print("Don't stop")nil Versus None
Luau nil represents absence and removes a table key when assigned to it. Python None is a storable singleton: assigning it to a dictionary key preserves that entry. Test absence with is None. A missing dictionary subscript raises KeyError instead of returning…
Luau1local seats = nil2print(seats == nil)3local values = {seat = 2}4values.seat = nil5print(values.seat == nil)Python1seats = None2print(seats is None)3available = False4print(available)Sequence Tables to Lists
Luau sequence conventions normally use consecutive indexes beginning at one. Python lists begin at zero, and negative indexes count backward from the end. append mutates a list and returns None. A Python None element is a real slot that counts toward length.…
Luau1local items = {4, 8}2table.insert(items, 12)3print(items[#items])4print(items[1])Python1items = [4, 8]2items.append(12)3print(items[-1])4print(items[:2])Numeric for to range
Luau numeric for includes its endpoint when the step reaches it, while Python range excludes its stop. Python for directly iterates element objects without requiring an ipairs-style pair. Reassigning the loop name does not replace an integer list slot, but…
Luau1for _, value in ipairs({2, 4}) do print(value) end2for i = 0, 3 do print(i) endPython1for value in [2, 4]:2 print(value)3for i in range(3):4 print(i)Returns and Shared Parameters
Python def introduces a function with a colon and indented body; an explicit return supplies its result. Falling through returns None, while a Luau fallthrough produces no values that assignment can adjust to nil. Python parameters refer to supplied objects…
Luau1local function twice(value)2 return value * 23end4print(twice(4))Python1def twice(value):2 return value * 23print(twice(4))Input and Exact Text
Input facilities depend on the Luau host; this course’s CLI provides io.read, returning nil when input ends. Python input strips the final newline and raises EOFError at exhaustion. strip removes surrounding whitespace and split without arguments handles…
Luau1local label = (" Green tea "):match("^%s*(.-)%s*$")2local cents = 3053print(string.format("%s: %d.%02d", label, math.floor(cents / 100), cents % 100))Python1label = " Green tea ".strip()2cents = 3053print(f"{label}: {cents // 100}.{cents % 100:02d}")
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsFrom Luau to Python
6 lessonsValues and Decisions
5 lessonsTables to Typed Collections
5 lessonsIteration and Transformations
5 lessonsFunctions and Closures
5 lessonsErrors and Modules
5 lessonsClasses Beyond Metatables
6 lessonsComposition and Dispatch
5 lessonsProject: Order Processing
4 lessonsApply Your Luau Experience
2 lessonsFrequently asked questions
Who is Python for Luau Developers for?
For people who already write Luau and want to learn Python. Each lesson starts from Luau you know and shows how Python does the same thing, so you skip the beginner basics.
Do I need to know Python already?
No. The course starts with your first Python program. You need Luau basics: variables, conditions, loops, functions and collections.
How many lessons does Python for Luau Developers have?
Python for Luau Developers contains 48 interactive lessons you can complete at your own pace.
What does Python for Luau Developers cover?
The course is organized into chapters covering: From Luau to Python, Values and Decisions, Tables to Typed Collections, Iteration and Transformations, and more.
Is Python for Luau Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.