self documenting kwarg passing in functions similar to f-strings in python3.8

Hi all,
Not sure if this feature already exists in python or if it has been proposed already but it would be extremely helpful for me and doesn't seem too difficult to implement.
I often write functions with really long kwarg names that call other functions that share a kwarg name. What I currently have is something like (very simplified example)
def function1(x, y, some_really_long_kwarg=True, **kwargs): other_kwarg = x>y function2(x, y, some_really_long_kwarg=some_really_long_kwarg, other_kwarg=other_kwarg) return
What I would like is to be able to write something like
def function1(x, y, some_really_long_kwarg=True, **kwargs): other_kwarg = x>y function2(x, y, some_really_long_kwarg=, other_kwarg=) return
where the kwarg= behaves similarly to how it does for f-strings in python3.8 when you write something like f'{other_kwarg=}'

There was a long discussion about a year ago: https://mail.python.org/archives/list/python-ideas@python.org/thread/SIMIOC7...
Eric
On 3/18/2021 12:28 AM, alexei.ciobanu@adelaide.edu.au wrote:
Hi all,
Not sure if this feature already exists in python or if it has been proposed already but it would be extremely helpful for me and doesn't seem too difficult to implement.
I often write functions with really long kwarg names that call other functions that share a kwarg name. What I currently have is something like (very simplified example)
def function1(x, y, some_really_long_kwarg=True, **kwargs): other_kwarg = x>y function2(x, y, some_really_long_kwarg=some_really_long_kwarg, other_kwarg=other_kwarg) return
What I would like is to be able to write something like
def function1(x, y, some_really_long_kwarg=True, **kwargs): other_kwarg = x>y function2(x, y, some_really_long_kwarg=, other_kwarg=) return
where the kwarg= behaves similarly to how it does for f-strings in python3.8 when you write something like f'{other_kwarg=}' _______________________________________________ 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/AOWAHG... Code of Conduct: http://python.org/psf/codeofconduct/
participants (2)
-
alexei.ciobanuļ¼ adelaide.edu.au
-
Eric V. Smith