Sending a user defined python function into 'Draw()'

If I define a function in a C macro, for example:

double myfunction(double val = 0) { ... return something; }
then the following works in PyRoot:

gROOT.ProcessLineSync('.L Cfunction.C') tree.Draw("myfunction(evt)")

Is it possible for me to do this with a function defined in python instead of C?


Can perhaps try a TF1, which can take a python function as argument to its ctor. Otherwise through the TPython iface, which will be slow.