Here's a script to find places where this proposal could be useful. Try it
on a directory.
```python
import ast
import linecache
import sys
from pathlib import Path
root = Path(sys.argv[1])
def main():
for path in root.rglob("**/*.py"):
source = path.read_text()
try:
tree = ast.parse(source)
except SyntaxError:
continue
for node in ast.walk(tree):
if isinstance(node, ast.Call):
def is_same_name(keyword: ast.keyword):
return (
isinstance(keyword.value, ast.Name)
and keyword.value.id == keyword.arg
)
args = node.keywords
elif isinstance(node, ast.Dict):
def is_same_name(pair):
key, value = pair
return (
isinstance(value, ast.Name) and
isinstance(key, (ast.Constant, ast.Str)) and
value.id == key.s
)
args = zip(node.keys, node.values)
else:
continue
threshold = 3
if sum(map(is_same_name, args)) < threshold:
continue
print(f'File "{path}", line {node.lineno}')
for lineno in range(node.lineno, node.end_lineno + 1):
print(linecache.getline(str(path), lineno), end="")
print()
main()
```
On Fri, Apr 17, 2020 at 8:40 PM Paul Svensson
On Fri, 17 Apr 2020, Alex Hall wrote:
Perhaps an easier next step would be to get better data about people's opinions with a simple poll? Is there a standard way to vote on things in this but it's easy and may inform what to do next.
For what it's worth, I'm a strong -1 on this whole thing, regardless of syntax. I think passing a lot of same-named parameters is an anti-pattern, that should be discouraged, not made easier. Passing an occasional x=x to so some function no disaster; if it happens often enough to be a problem, IMNSHO, you should look to change your coding style, not the language.
/Paul _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/B3R63F... Code of Conduct: http://python.org/psf/codeofconduct/