Post AZANJVM9ePpGn2epOa by nedbat@hachyderm.io
(DIR) More posts by nedbat@hachyderm.io
(DIR) Post #AZANJVM9ePpGn2epOa by nedbat@hachyderm.io
2023-08-27T16:13:20Z
0 likes, 0 repeats
Python proposal (inspired by Lua!):args = {'a':1, 0:98, 1:99, 'b':2}f(**args)is the same as:f(98, 99, a=1, b=2)I've long wished to have one thing that could serve as both *args and **kwargs. Int keys are already invalid, so nothing would break.
(DIR) Post #AZANJWs618yDUObqoy by tek@freeradical.zone
2023-08-27T19:54:36Z
0 likes, 0 repeats
@nedbat What if 0 is undefined but 1 is?How would you right the type declaration for that dict?I think I, and my other experienced colleagues, could find this convenient sometimes. I think it would be hard for a new Pythonista to follow.
(DIR) Post #AZAkjCUghX30lRs21Q by sashk@mastodon.social
2023-08-28T00:16:58Z
0 likes, 0 repeats
@tek @nedbat i guess it should l be an TypeError exception, where one of two positional arguments is missing. same as>>> def f(a, b, k=1, j=8):... pass...>>> f(1, k=91, j=92)Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: f() missing 1 required positional argument: 'b'
(DIR) Post #AZAnt5LkPxF7Mi5sjg by tek@freeradical.zone
2023-08-28T00:52:23Z
0 likes, 0 repeats
@sashk @nedbat That’s already more complicated than I’m comfortable with.