[Python-ideas] Keyword only argument on function call

Jonathan Fine jfine2358 at gmail.com
Tue Sep 11 14:53:34 EDT 2018


I wrote:

> In my opinion, the technically well-informed would prefer something
> like __args__ or __locals__ instead of __params__, for the current
> purpose.
>
> Finally, __params__ would simply be the value of __locals__ before any
> assignment has been done.

Following this up, I did a search for "__locals__" Python. The most
interesting link I found was

<quote>
Implement PEP 422: Simple class initialisation hook
https://bugs.python.org/issue17044#msg184195

Nick Coghlan wrote:
Oh, that's bizarre - the presence of __locals__ is a side effect of
calling locals() in the class body. So perhaps passing the namespace
as a separate __init_class__ parameter is a better option.
</quote>

So it looks like (i) there's some complexity associated with locals(),
and (ii) if we wish, it seems that __locals__ is available as a
keyword identifier.

Finally, another way to see that there's no race condition. The Python
debugger supports inspection of stack frames. And it's a pure Python
module.

https://docs.python.org/3/library/pdb.html
https://github.com/python/cpython/tree/3.7/Lib/pdb.py

-- 
Jonathan


More information about the Python-ideas mailing list