Python for GDScript Developers
Transfer GDScript experience to Python: compare values, control flow, collections, functions, and object behavior. Build a connected multi-file order processor and port an inventory program.
GDScript and Python side by side
The same program in GDScript and in Python, from the lessons of this course.
Print Is Not prints
GDScript resembles Python but is a separate language tied to Godot. GDScript print concatenates its arguments without added spaces; prints inserts spaces. Python print inserts spaces by default. Both support # comments and quoted strings, but Python f-strings…
GDScript1extends SceneTree2func _init():3 var name = "Ada"4 print("Hi ", name, "!")5 quit()Python1name = "Ada"2print(f"Hi {name}", "!")Null and None
GDScript uses null, true and false; Python uses None, True and False. Python tests absence with is None. GDScript's is operator tests a type, whereas Python is tests identity, so an absence check is not a direct keyword-for-keyword port. A dictionary can…
GDScript1extends SceneTree2func _init():3 var data = {"seats": null}4 print(data["seats"] == null)5 print(data.has("seats"))6 quit()Python1data = {"seats": None}2print(data["seats"] is None)3print("seats" in data)Array and List APIs
Godot Array and Python list are ordered, growable containers with zero-based and negative indexing. Their APIs differ: GDScript size() becomes len, append remains a mutation, and Python slicing uses colon syntax. A Python slice creates a new outer list and…
GDScript1extends SceneTree2func _init():3 var items = [4, 8]4 items.append(12)5 print(items[-1])6 quit()Python1items = [4, 8]2print(items.append(12))3print(items[-1])Ranges and Rebinding
Both languages use for with iterables and half-open range endpoints. Python range returns a range object rather than a materialized list of all integers. A Python loop variable is a binding to each visited value; rebinding it does not replace a list slot.…
GDScript1extends SceneTree2func _init():3 var values = [2, 4]4 for value in values:5 prints(value)6 for n in range(3):7 print(n)8 quit()Python1values = [2, 4]2for value in values:3 value += 14print(*values)Func, Def, and Returned Values
GDScript func becomes Python def. A Python function without an explicit result returns None, analogous to an untyped GDScript function's null result. Both languages share mutable containers passed to functions, so appending through a parameter can change the…
GDScript1extends SceneTree2func add_item(items):3 items.append(9)4func _init():5 var items = [1]6 add_item(items)7 print(items.size())8 quit()Python1def add_item(items):2 items.append(9)3items = [1]4add_item(items)5print(len(items))Console Work Outside Godot
Python input reads text from standard input and removes its trailing newline; int converts numeric text. A GDScript game normally obtains input through engine APIs and events, which do not exist in ordinary Python. These lessons use a command-line contract.…
GDScript1extends SceneTree2func _init():3 var label = " Green tea ".strip_edges()4 var cents = 3055 print("%s: %.2f" % [label, cents / 100.0])6 quit()Python1label = " Green tea ".strip()2cents = 3053print(f"{label}: {cents / 100:.2f}")
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsFrom GDScript to Python
6 lessonsValues and Decisions
5 lessonsCollections and Shared State
5 lessonsIteration and Transformations
5 lessonsFunctions and Closures
5 lessonsInput, Errors, and Modules
5 lessonsInstances and Shared State
6 lessonsComposition and Dispatch
5 lessonsProject: Order Processing
4 lessonsApply Your GDScript Experience
2 lessonsFrequently asked questions
Who is Python for GDScript Developers for?
For people who already write GDScript and want to learn Python. Each lesson starts from GDScript 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 GDScript basics: variables, conditions, loops, functions and collections.
How many lessons does Python for GDScript Developers have?
Python for GDScript Developers contains 48 interactive lessons you can complete at your own pace.
What does Python for GDScript Developers cover?
The course is organized into chapters covering: From GDScript to Python, Values and Decisions, Collections and Shared State, Iteration and Transformations, and more.
Is Python for GDScript Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.