It seems very obvious to me that kwd args only should be valid, as Greg Ewing said, if kwd args are added.
I'm less sure about no arguments, but perhaps. On Fri, Aug 14, 2020, 8:11 AM Jonathan Fine <jfine2...@gmail.com> wrote: > Storing function call results would be a use case. For this, look at the > implementation of functools.lru_cache. > So maybe something like this?: from functools important storagefunc @storagefunc def fibonacci(*, n): return fibonacci[n=n-1]+fibonacci[n=n-2] >>> fibonacci[n=1] = 0 >>> fibonacci[n=2] = 1 >>> fibonacci[n=4] 2 Of course this example function may not absolutely require kwd only args but any other example that can be contrived probably doesn't absolutely require them either. For a specific example, a simple ad hoc way of recording data. For example > >>> height[x=10, y=14] = 2010 > > We can already use dictionaries in this way, as in > >>> height[10, 14] = 2010 > > So this is a bit like using named tuples instead of tuples. > This seems like another nice usage to me. But isn't it important to identify what the underlying storage is, and the rest of the API, before I would want to use something like this? After all I can do these with both a list and dictionary: mylist[0] mydict[0] But the one I want to use is determined somewhat by what else I intend to do with it, and how it behaves under the hood... Use a ictionary for very fast item access, for example. List or tuple for ordered things. >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@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/LU2WMXIXQLU7K7F5UQNBVZ53EE3PBKWH/ Code of Conduct: http://python.org/psf/codeofconduct/