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

Ron Adam ron3200 at gmail.com
Sat Nov 5 05:52:59 CET 2011


On Sat, 2011-11-05 at 00:15 +0100, Jan Kaliszewski wrote:
> Guido van Rossum dixit (2011-11-04, 13:49):
> 
> > On Fri, Nov 4, 2011 at 12:38 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> > > On Sun, 30 Oct 2011 09:52:15 +1000
> > > Nick Coghlan <ncoghlan at gmail.com> wrote:
> [snip]
> > >> For nested functions, I suggest adding something to the qname to
> > >> directly indicate that the scope is hidden. Adding parentheses to the
> > >> name of the outer function would probably work:
> > >>
> > >>     f().g
> > >
> > > I don't know, I find the "()" a bit too smart. I'd like Guido's
> > > advice on the matter.
> > 
> > Hm. Both 'f.g' and 'f().g' for f().__qname__ are misleading, since both
> > look like valid expressions but neither will actually retrieve the intended
> > object. I'd be tempted to return something like '<local in f>.g' where 'f'
> > would be f.__qname__. And yes, if f.__qname__ were '<local in xyzzy>.f',
> > then f().__qname__ should be '<local in <local in xyzzy>.f>.g'.
> > 
> > Alternatively perhaps I could live with 'f.<locals>.g' and
> > 'xyzzy.<locals>.f.<locals>.g'.

Too many dots I think.


> And what about:
> 
>     <f locals>.g
> and
>     <<xyzzy locals>.f locals>.g

Better, but I don't think you need to nest it to indicate that
relationship. I would use a colon instead of a dot to indicate a
namespace relationship.
   
    f.g    g is an attribute of f
    f[g]   g is in the container f
    f:g    g is in the namespace f

So I think I'd one of...

     <xyzzy locals>:<f locals>:g
     <xyzzy:f:g>

A slice is used a completely different context.


Cheers,
   Ron







More information about the Python-ideas mailing list