[Tutor] understanding **kwargs syntax

Peter Otten __peter__ at web.de
Thu Sep 8 13:23:30 CEST 2011

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 would guess it's a readability concern. Consider a simple function

def f(x, y=0):
    print x + y

for a in [1], "ab", "abc":

Can you tell what will be printed immediately? For me

f("a", "b")
f("a", "b", "c")

is much easier to predict.

That said, there are valid usecases for * and ** "magic", and of course 
pylint cannot take the tradeoffs into account. Therefore don't take pylint's 
warnings as gospel.

PS: the exception is intentional

More information about the Tutor mailing list