[Python-ideas] Treat underscores specially in argument lists
Stephen J. Turnbull
stephen at xemacs.org
Tue Feb 17 08:58:55 CET 2015
Andrew Barnert writes:
> So anyway, what if you needed the index, but not the name or mode?
> You can't use *_ to get around that; you have to come up with two
> dummy names. That's a bit annoying.
If there's one such function, I'd say "suck it up". If there are two
or more, hit it with a two-by-four and it will submit:
def twobyfour (func):
def wrapper(real1, dummy1, real2, dummy2):
return func(real1, real2)
return wrapper
> >> Why are you ignoring *any* arguments?
I wouldn't express the idea that way. Obviously we're ignoring
arguments because there's a caller that supplies them.
Rather, I'd say "in my experience ignoring arguments means a badly
designed API that should be refactored." That's true in callbacks as
well as in any other function. Granted, sometimes you can't refactor,
but I think more often than not ignoring arguments is a code smell and
you can.
More information about the Python-ideas
mailing list