Python Dynamic Create Function In R