Python Persistent Variable In Function In R