Generator in python, Bash gens ported to python