Reimplement gd.sh in python using the dictionary API