A script is plain Python, executed in a namespace that additionally provides the names described below. The simplest possible script:
<syntaxhighlight lang="python"> for person in people(): row(person.gramps_id, person.name.first_name, person.surname.surname, person.gender)</syntaxhighlight>
=== Iterating over records ===
A script can <code>import</code> a plain <code>.py</code> module the normal way, as long as that module lives next to the script's own <code>.gram.py</code> file, or in the bundled <code>scripts</code> folder. This is a convenient way to share functions between several of your own scripts instead of copy-pasting them. See <code>scripts/script_helpers.py</code> and <code>scripts/11_import_example.gram.py</code> for a working example:
<syntaxhighlight lang= from script_helpers import decade columns("Decade", "pythonBirths">) counts = counter()from script_helpers import for person in people(): birth = person.birth if birth: year = birth.get_date_object().get_year() if year: counts[decade(year)] += 1 for decade_start, count in sorted(counts.items()): row("%ds" % decade_start, count)
columns("Decade", "Births")
counts = counter()
for person in people():
birth = person.birth
if birth:
year = birth.get_date_object().get_year()
if year:
counts[decade(year)] += 1
for decade_start, count in sorted(counts.items()):
row("%ds" % decade_start, count)
</syntaxhighlight>
== Record fields ==