[Python-ideas] Treat underscores specially in argument lists (original) (raw)

Devin Jeanpierre jeanpierreda at gmail.com
Tue Feb 17 09:04:13 CET 2015


Our experiences differ, then. I've never seen arguments unused that wasn't fairly justifiable and OK with me.

OTOH, I have seen code break because it renamed a parameter to "unused_foo" instead of foo, and when the method was called with foo=2... kablooie.

-1 on encouraging the antipattern of renaming your public interfaces to indicate implementation details.

-- Devin

On Mon, Feb 16, 2015 at 11:58 PM, Stephen J. Turnbull <stephen at xemacs.org> wrote:

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.


Python-ideas mailing list Python-ideas at python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/



More information about the Python-ideas mailing list