<p>I think you're all overthinking this. We want a notation that:<br>
1. Makes it clear attribute access won't work <br>
2. Indicates where the nested definition really lives<br>
3. Gives a reasonable error message if you do try to evaluate it</p>
<p>"f.<locals>.g" ticks all those boxes, so it's fine. </p>
<p>--<br>
Nick Coghlan (via Gmail on Android, so likely to be more terse than usual)</p>
<div class="gmail_quote">On Nov 6, 2011 4:02 AM, "Ron Adam" <<a href="mailto:ron3200@gmail.com">ron3200@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Sat, 2011-11-05 at 11:04 -0600, Eric Snow wrote:<br>
> On Sat, Nov 5, 2011 at 10:32 AM, Éric Araujo <<a href="mailto:merwok@netwok.org">merwok@netwok.org</a>> wrote:<br>
> > Hi,<br>
> ><br>
> >> I would like to propose the following PEP for discussion and, if<br>
> >> possible, acceptance. I think the proposal shouldn't be too<br>
> >> controversial (I find it quite simple and straightforward myself :-)).<br>
> >> [snip PEP]<br>
> ><br>
> > +1.<br>
> ><br>
> > For nested functions, I too think that 'f.<locals>.g' has too many dots;<br>
> > I like '<local in f>.g' or '<f locals>.g'.<br>
><br>
> I like it too but don't think it's too many dots.<br>
><br>
> The function from which the locals came _could_ be rolled into the<br>
> brackets.  However, in the context of some object (like the class X to<br>
> which f belongs), 'X.f.<locals of f>.g' makes more sense in that case<br>
> than 'X.<locals of f>.g', since the locals is related to f and not X.<br>
> But, then the f is sort of redundant, so you go back to<br>
> 'X.f.<locals>.g', and '<locals>' is still sort of unambiguous.<br>
><br>
> The disconnect is that <locals> is an externally anonymous namespace<br>
> resulting from a call, rather than bound to any external namespace<br>
> (like an object).  Perhaps it would be appropriate to use<br>
> 'X.f().<locals>.g' to make that clear.<br>
<br>
I think if you consider locals in f as an implementation detail of f's<br>
name space rather than a sub item of f, it's not as confusing.  It's<br>
better to think of locals as being part of f, rather than in f.  That is<br>
why <f locals> makes more sense than f.<locals>.  For example locals is<br>
in f's frame object, so if you follow that reasoning you get.<br>
f.<frame>.<locals>,  but I don't think we need all that.<br>
<br>
Hmmm...  I think it actually should be spelled...<br>
<br>
      f.<local g><br>
<br>
Following a pattern of...<br>
<br>
      x                 object x<br>
      x.f               f in object x<br>
      x.f.<local g>     local g in f in x<br>
<br>
That's both clear and concise.<br>
<br>
Cheers,<br>
   Ron<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</blockquote></div>