Namespaces: The Whole Story

Now that we’ve examined class and instance objects, the Python namespace story is complete. For reference, I’ll quickly summarize all the rules used to resolve names here. The first things you need to remember are that qualified and unqualified names are treated differently, and that some scopes serve to initialize object namespaces:

 

广告:个人专属 VPN,独立 IP,无限流量,多机房切换,还可以屏蔽广告和恶意软件,每月最低仅 5 美元

 
  • Unqualified names (e.g., X) deal with scopes.
  • Qualified attribute names (e.g., object.X) use object namespaces.
  • Some scopes initialize object namespaces (for modules and classes).