How To Write A Callback Function In Python