Luau for Python Developers
Bring Python experience to general Luau: tables, control flow, typed function signatures, runtime contracts, modules and metatable objects. Build a stock ledger and port two Python programs.
Python and Luau side by side
The same program in Python and in Luau, from the lessons of this course.
Print and Comment
Python and Luau both run statements at the top level. Luau comments start with --. Strings use either quote style. Luau joins strings with ..; print separates multiple values with tabs, unlike Python spaces.
Python1print("Hi" + ", Ada")Luau1local name = "Ada"2print(`Hi, {name}`)None and Missing Fields
Luau nil represents absence, much like Python None. But assigning nil to a table field removes that key. Assigning false keeps a key. Read a missing field to get nil, rather than a Python dictionary KeyError.
Python1d = {"x": None}2print("x" in d)Luau1local d = {x = nil}2print(d.x == nil)Ranges to Numeric for
Luau numeric for i = start, stop, step do includes the stop if reached. Python range excludes it. The default Luau step is one. Use a negative step for descending traversal.
Python1print(sum(range(1, 4)))Luau1local total = 02for i = 1, 3 do total = total + i end3print(total)Functions and Returns
Python annotations and Luau annotations both need separate tooling for static analysis in this course. Python enforces ordinary required argument counts at runtime; Luau missing parameters instead receive nil.
Python1def twice(x):2 return x * 23print(twice(4))Luau1local function twice(x: number): number return x * 2 end2print(twice(4))Lists as Dense Tables
Luau tables serve as both sequences and maps. Keep a sequence dense from key 1 through its length. table.insert appends by default; table.remove(t, i) shifts later elements down. Use table.concat to join strings.
Python1a = ["a", "b", "c"]2a.pop(1)3print(",".join(a))Luau1local a = {"a", "b", "c"}2table.remove(a, 2)3print(table.concat(a, ","))Sorting and Comparators
Python sorted creates a new list. Luau table.sort rearranges its input and returns no result. A custom Luau comparator returns true when its first argument must precede its second. Comparators must be strict; use a tie-breaker when output order matters.
Python1a = [3, 1, 2]2b = sorted(a)3print(a[0])Luau1local a={3,1,2}2table.sort(a)3print(a[1])
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsFirst Luau Programs
6 lessonsValues and Decisions
5 lessonsIteration and Flow
5 lessonsFunctions and Closures
5 lessonsTables as Collections
5 lessonsOrdering, Modules and Errors
5 lessonsObjects and Owned State
5 lessonsComposition and Object Lookup
6 lessonsProject: Stock Ledger
4 lessonsFinal Python Ports
2 lessonsFrequently asked questions
Who is Luau for Python Developers for?
For people who already write Python and want to learn Luau. Each lesson starts from Python you know and shows how Luau does the same thing, so you skip the beginner basics.
Do I need to know Luau already?
No. The course starts with your first Luau program. You need Python basics: variables, conditions, loops, functions and collections.
How many lessons does Luau for Python Developers have?
Luau for Python Developers contains 48 interactive lessons you can complete at your own pace.
What does Luau for Python Developers cover?
The course is organized into chapters covering: First Luau Programs, Values and Decisions, Iteration and Flow, Functions and Closures, and more.
Is Luau for Python Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.