[Python-ideas] PEP 3155 - Qualified name for classes and functions

Eric Snow ericsnowcurrently at gmail.com
Sat Nov 5 18:04:47 CET 2011


On Sat, Nov 5, 2011 at 10:32 AM, Éric Araujo <merwok at netwok.org> wrote:
> Hi,
>
>> I would like to propose the following PEP for discussion and, if
>> possible, acceptance. I think the proposal shouldn't be too
>> controversial (I find it quite simple and straightforward myself :-)).
>> [snip PEP]
>
> +1.
>
> For nested functions, I too think that 'f.<locals>.g' has too many dots;
> I like '<local in f>.g' or '<f locals>.g'.

I like it too but don't think it's too many dots.

The function from which the locals came _could_ be rolled into the
brackets.  However, in the context of some object (like the class X to
which f belongs), 'X.f.<locals of f>.g' makes more sense in that case
than 'X.<locals of f>.g', since the locals is related to f and not X.
But, then the f is sort of redundant, so you go back to
'X.f.<locals>.g', and '<locals>' is still sort of unambiguous.

The disconnect is that <locals> is an externally anonymous namespace
resulting from a call, rather than bound to any external namespace
(like an object).  Perhaps it would be appropriate to use
'X.f().<locals>.g' to make that clear.

-eric


>
> polka-dots-ly yours
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



More information about the Python-ideas mailing list