GDScript cheat sheet

GDScript is a dynamically typed scripting language with a Python-like syntax. For example, the if, while, and for statements have exactly the same syntax in Python and GDScript.

The table below shows some differences between Python and GDScript that programmers will frequently encounter. You can find full GDScript documention on the Godot web site.

Python

GDScript

boolean constants

True, False

true, false

integers

any size

64-bit signed

integer division

//

/

chained comparisons

yes

no

type check operator

isinstance()

is




dynamic array type

list

Array

list/array length

len(l)

a.size()

* operator for repeating a sequence

yes

no

tuples

yes

no

assignment to pattern

yes

no




constant definition

(implicit)

const

variable definition

(implicit)

var

function declaration

def

func

lambda syntax

lambda x: x + 2

func(x): return x + 2

self

explicit

implicit

set type

yes

no




queue, priority queue types

yes

no