Fix Python code templates

They stopped working when auto-imports were removed.

This commit adds the proper imports, and cleans up
a few mistakes in the introductory comments.