straight copy from template python