Pretty sure you mean to use the and operator instead in order for the expression to evaluate as d.
Your trick wouldn’t work for keyword arguments though:
foo(a, #_option1=True, option2=3)
And with your trick requiring that many keystrokes I would just use my good old trick of hitting Enter and commenting out the individual argument, positional or not:
A few more keystrokes required but indeed still quite workable, and better than having to scroll to the end of a code block with the docstring approach I usually take when working in an editor without support for block commenting:
'''
def vec_add(
x,
y
):
"double-quoted docstring"
....
'''
Most production systems only have the most basic editors installed. This feature would’ve (however slightly) benefitted our operations team on several occasions when a critical error occurred on a production system where it was painfully obvious what a quick fix in code could be to immediately stop the bleed, where every keystroke and mouse movement counts in a race against time.
Yes, of course it is only meant for an obvious quick fix from an on-call operations team member. A full post mortem and due review process will always follow.
Acknowledging that the programming domains I’ve worked in may be rather niche, I recall commenting out parameters in some cases:
def jit_inline_fun(a: int, b: int, c: int):
...
where jit_inline_fun is jit compiled and then inlined.
So a call site like this:
result = jit_inline_fun(foo, bar, baz)
may end up calling into a module that is implemented in C, which will evaluate the JIT’d function. The delegation may have some embedded checks based on the declared types of the params.
So, a misalignment in the declaration of the parameter types (e.g. what should be “i32,i32,i32” is misdeclared as “*i32,…”) perhaps leads to an error, but the error might not clearly represent the problem in a manner recognizable to a user of the library, other than that a parameter is causing an issue.
In those cases I’ve found that commenting out a parameter can quickly resolve which param has an issue, where otherwise it can be very difficult to localize the problem, as errors are not always very interpretable.
Other cases that haven’t been addressed here are e.g. function invocations spread over multiple lines.
If something this trivial needs to be addressed in production, your organization needs better code review and deployment processes, not a change to Python’s grammar.