Moved Python specific functionality into its own helper file