Menu
CoddyTech
Course

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.

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

    Luau
    1-- Readable status2print("Status:", "ready")3print("Don't stop")
    Python
    1# A comment for readers2print("Status:", "ready")3print("Don't stop")
  2. 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…

    Luau
    1local seats = nil2print(seats == nil)3local values = {seat = 2}4values.seat = nil5print(values.seat == nil)
    Python
    1seats = None2print(seats is None)3available = False4print(available)
  3. 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.…

    Luau
    1local items = {4, 8}2table.insert(items, 12)3print(items[#items])4print(items[1])
    Python
    1items = [4, 8]2items.append(12)3print(items[-1])4print(items[:2])
  4. 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…

    Luau
    1for _, value in ipairs({2, 4}) do print(value) end2for i = 0, 3 do print(i) end
    Python
    1for value in [2, 4]:2    print(value)3for i in range(3):4    print(i)
  5. 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…

    Luau
    1local function twice(value)2    return value * 23end4print(twice(4))
    Python
    1def twice(value):2    return value * 23print(twice(4))
  6. 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…

    Luau
    1local label = ("  Green tea  "):match("^%s*(.-)%s*$")2local cents = 3053print(string.format("%s: %d.%02d", label, math.floor(cents / 100), cents % 100))
    Python
    1label = "  Green tea  ".strip()2cents = 3053print(f"{label}: {cents // 100}.{cents % 100:02d}")

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

Apply Your Luau Experience

2 lessons

More courses for Luau developers

Learn Python from another language

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

Coddy programming languages illustration

Start Python for Luau Developers for free

Get started