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

Nick Coghlan ncoghlan at gmail.com
Tue Nov 8 02:16:42 CET 2011


On Tue, Nov 8, 2011 at 1:34 AM, Barry Warsaw <barry at python.org> wrote:
> Nice PEP, and +1 for the concept (with Guido's preferred format).  However,
> "qname" is pretty obscure and I only guessed what the "q" stood for by reading
> the title of the PEP.
>
> It seems to me that this attribute represents the dotted path from module
> globals to the object.  You have to be careful not to confuse this with a file
> system path, so something like __dotted_name__, __dotted_path__, or
> __full_name__ perhaps.  I don't much care, but I do think cryptic
> abbreviations should be avoided.

For both this PEP and PEP 395 (module aliasing), we need a new term
for a name that is "usually the same as __name__, but different in
some cases where __name__ lacks necessary detail".

"qualified name" meets that criteria in both cases by covering all
situations where __name__ underspecifies things. For classes and
functions, __name__ leaves out the nesting information, so you can't
reliable locate the definition based solely on __module__ and
__name__. In the case of modules, we occasionally alter __name__ for
other purposes (such as indicating the main module or to ensure
objects get serialised with the correct module information when the
file layout doesn't match the nominal module layout). The new
qualified names will address all those cases without causing backwards
compatibility issues for existing uses of __name__. Hence, -1 on terms
other than "qualified", because they don't fit the module aliasing use
case (which involves name that are neither scoped, nor necessarily
dotted) and would require me to come up with yet another term for what
is essentially the same concept.

The question then is whether or not to introduce "qname" as an
officially documented abbreviation for "qualified name". And to that I
say, "Hell, yes".

1. "qualifiedname" and "qualified_name" is just too damn long. I want
an abbreviation.
2. "qualname" is too hard to say
3. People are going to come up with an abbreviation anyway, so we may
as well make it an official one so we get to benefit as well

Being able to talk about "names and qnames" without ambiguity will
make all of the affected code much easier to update and discuss than
if we insist on using the full "qualified name" term every time.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list