8

In Python: what is a "qualified name" or "unqualified name"?

I've seen it mentioned a couple of times, but no explanation as to what it is.

1 Answer 1

14

It is the path from top-level module down to the object itself.

See PEP 3155, Qualified name for classes and functions.

If you have a nested package named foo.bar.baz with a class Spam, the method ham on that class will have a fully qualified name of foo.bar.baz.Spam.ham. ham is the unqualified name.

A qualified name lets you re-import the exact same object, provided it is not an object that is private to a local (function) namespace.

Sign up to request clarification or add additional context in comments.

4 Comments

Are objects the only thing that have qualified names? Or can classes also have them? (Or is a class an object as well?)
Does a module have a qualified name?
And what is the difference (if any) between a qualified name and a fully qualified name?
Classes are objects; modules (objects too!) have a qualified name, that is what you use when you use an absolute import. Qualified names are not as formal as you think they are; the terms are not that ridgidly defined.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.