[Tutor] understanding **kwargs syntax
Alan Gauld
alan.gauld at btinternet.com
Thu Sep 8 15:53:19 CEST 2011
On 08/09/11 11:10, John wrote:
> Following up on this...
>
> Why does pylint seem to think it is a bad idea?
>
> Description Resource Path Location Type
> ID:W0142 plot_ts_array_split_x: Used * or **
> magic tsplot.py /research.plot line 299 PyLint Problem
I assume because it is a bad idea in most cases. If you know what the
arguments are going to be then specify them. Otherwise you can get all
sorts of rubbish being passed in that you have to figure out how to deal
with. That's never a good place to be.
But occasionally you have to do things that are less than ideal.
And *args/**kwargs are useful in those situations, just don't
use them unless you have to.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list