Keyword arguments and python simpletons

From: Tim Head <betatim_at_gmail.com>
Date: Wed, 12 May 2010 09:51:07 -0500


Hello,

after being very confused for a bit I had someone who actually knows C++ explain to me why out of order default arguments (python keyword arguments) can't work in C++.

The specific case was calling ProfileX() form python not doing what I expected it to do.

h.ProfileX("fdsg", 0, h.GetNbinsY(), "s")

was doing the right thing but

h.ProfileX(option="s")

did not.

I got reminded that this is basically impossible to have out of order arguments in C++, and having pyroot filling in the default arguments at run time is probably also not a very good idea.

However I was wondering if it would be possible to teach pyroot to hit the user each time they try to do this? Mainly because the above will run and produce results and for a python person it will take some time to realise that this very natural python feature just does not fly in C++. So I atleast would be very happy to have a pyroot extension which will cause the above code to fail instead of running but clearly not doing what I think it is doing.

Thanks,
Tim

-- 
http://tim.jottit.com/
Received on Wed May 12 2010 - 16:51:12 CEST

This archive was generated by hypermail 2.2.0 : Wed May 12 2010 - 17:50:02 CEST