Menu
CoddyTech
Course

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.

  1. 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.

    Python
    1print("Hi" + ", Ada")
    Luau
    1local name = "Ada"2print(`Hi, {name}`)
  2. 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.

    Python
    1d = {"x": None}2print("x" in d)
    Luau
    1local d = {x = nil}2print(d.x == nil)
  3. 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.

    Python
    1print(sum(range(1, 4)))
    Luau
    1local total = 02for i = 1, 3 do total = total + i end3print(total)
  4. 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.

    Python
    1def twice(x):2    return x * 23print(twice(4))
    Luau
    1local function twice(x: number): number return x * 2 end2print(twice(4))
  5. 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.

    Python
    1a = ["a", "b", "c"]2a.pop(1)3print(",".join(a))
    Luau
    1local a = {"a", "b", "c"}2table.remove(a, 2)3print(table.concat(a, ","))
  6. 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.

    Python
    1a = [3, 1, 2]2b = sorted(a)3print(a[0])
    Luau
    1local a={3,1,2}2table.sort(a)3print(a[1])

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

More courses for Python developers

Learn Luau from another language

Frequently 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.

Coddy programming languages illustration

Start Luau for Python Developers for free

Get started