{"id":4690,"date":"2022-08-16T10:15:34","date_gmt":"2022-08-16T10:15:34","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=4690"},"modified":"2022-08-16T10:15:34","modified_gmt":"2022-08-16T10:15:34","slug":"what-is-the-namespace-in-python","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/","title":{"rendered":"What is the namespace in Python ?"},"content":{"rendered":"<ul>\n<li style=\"text-align: justify;\">In python a namespace is a system that has a unique name for each and every object.<\/li>\n<li style=\"text-align: justify;\">An object might be a\u00a0method or a variable and python itself maintains a namespace in the form of a Python dictionary.<\/li>\n<li style=\"text-align: justify;\">Inside every directory that one can have multiple directories having a file with the same name.<\/li>\n<li style=\"text-align: justify;\">The role of a namespace is like a surname, in real time example.<\/li>\n<li style=\"text-align: justify;\">Python interpreter understands what exact method or variable one is trying to point to in the code, depending upon the namespace, on similar lines.<\/li>\n<li style=\"text-align: justify;\">In this Name which means name, a unique identifier and Space which talks something related to scope.<\/li>\n<li style=\"text-align: justify;\">In python a name might be of any\u00a0method or variable and space depends upon the location from where is trying to access a variable or a method.<\/li>\n<li style=\"text-align: justify;\">The namespace consists of three types, they are global namespace, built-in namespace, local namespace.<\/li>\n<\/ul>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-4691\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/types-of-namespaces.png\" alt=\"\" width=\"748\" height=\"663\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/types-of-namespaces.png 748w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/types-of-namespaces-300x266.png 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/types-of-namespaces-390x346.png 390w\" sizes=\"(max-width: 748px) 100vw, 748px\" \/><\/p>\n<ul>\n<li style=\"text-align: justify;\">If python interpreter runs solely without any user-defined modules, methods, classes, etc. Some functions like print (), id () is always present, these are built-in namespaces.<\/li>\n<li style=\"text-align: justify;\">If user creates a module, a global namespace gets created, later the creation of local functions creates the local namespace.<\/li>\n<li style=\"text-align: justify;\">The global namespace encompasses the local namespace and built-in namespace encompasses global namespace.<\/li>\n<li style=\"text-align: justify;\">If scope of an object ends, the lifetime of that namespace comes to an end, so the lifetime of a namespace depends upon the scope of objects.<\/li>\n<li style=\"text-align: justify;\">Hence there is no possible to access the inner namespace\u2019s objects from an outer namespace.<\/li>\n<\/ul>\n<h2 id=\"sample-code\">Sample Code<\/h2>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-python code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-python code-embed-code\"># Python program processing<br\/># global variable<br\/> <br\/>count = 10<br\/>def some_method ():<br\/>    global count<br\/>    count = count + 10<br\/>    print(count)<br\/>some_method ()<\/code><\/pre> <\/div>\n<h2 id=\"output\">Output<\/h2>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-4692\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/namespace.png\" alt=\"\" width=\"965\" height=\"242\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/namespace.png 965w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/namespace-300x75.png 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/namespace-768x193.png 768w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/namespace-390x98.png 390w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/namespace-820x206.png 820w\" sizes=\"(max-width: 965px) 100vw, 965px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In python a namespace is a system that has a unique name for each and every object. An object might be a\u00a0method or a variable and python itself maintains a namespace in the form of a Python dictionary. Inside every directory that one can have multiple directories having a file with the same name. The [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5608],"tags":[18149,18160,18159,18151,18154,18163,18162,18152,18148,18150,18161,18164,18153,18140,18157,18155,18156,18158],"class_list":["post-4690","post","type-post","status-publish","format-standard","hentry","category-python","tag-enclosing-namespace-in-python","tag-example-for-namespace-in-python","tag-explain-namespaces-in-python","tag-namespace-in-python","tag-namespace-in-python-hackerrank-solution","tag-order-of-namespace-in-python","tag-python-list-namespaces","tag-python-namespace-object","tag-types-of-namespaces-in-python","tag-use-of-namespace-in-python","tag-what-is-global-namespace-in-python","tag-what-is-namespace-in-c-with-example","tag-what-is-namespace-in-python-with-example","tag-what-is-scope-in-python","tag-what-is-the-default-namespace-a-program-will-run-in-python","tag-what-is-the-namespace-in-python","tag-what-is-the-order-of-namespace-in-which-python-looks-for-an-identifier","tag-what-is-the-use-of-namespace-in-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What is the namespace in Python ? - Python NameSpace - Wikitechy<\/title>\n<meta name=\"description\" content=\"What is the namespace in Python ? - In python a namespace is a system that has a unique name for each and every object.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is the namespace in Python ? - Python NameSpace - Wikitechy\" \/>\n<meta property=\"og:description\" content=\"What is the namespace in Python ? - In python a namespace is a system that has a unique name for each and every object.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-16T10:15:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/types-of-namespaces.png\" \/>\n<meta name=\"author\" content=\"webmaster\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webmaster\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-the-namespace-in-python\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-the-namespace-in-python\\\/\"},\"author\":{\"name\":\"webmaster\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#\\\/schema\\\/person\\\/f785ba3ecc599133e65ab6138042a3e4\"},\"headline\":\"What is the namespace in Python ?\",\"datePublished\":\"2022-08-16T10:15:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-the-namespace-in-python\\\/\"},\"wordCount\":295,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-the-namespace-in-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/types-of-namespaces.png\",\"keywords\":[\"enclosing namespace in python\",\"example for namespace in python\",\"explain namespaces in python\",\"namespace in python\",\"namespace in python hackerrank solution\",\"order of namespace in python\",\"python list namespaces\",\"python namespace object\",\"types of namespaces in python\",\"use of namespace in python\",\"what is global namespace in python\",\"what is namespace in c++ with example\",\"what is namespace in python with example\",\"what is scope in python\",\"what is the default namespace a program will run in python\",\"what is the namespace in python\",\"what is the order of namespace in which python looks for an identifier\",\"what is the use of namespace in python\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-the-namespace-in-python\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-the-namespace-in-python\\\/\",\"url\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-the-namespace-in-python\\\/\",\"name\":\"What is the namespace in Python ? - Python NameSpace - Wikitechy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-the-namespace-in-python\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-the-namespace-in-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/types-of-namespaces.png\",\"datePublished\":\"2022-08-16T10:15:34+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#\\\/schema\\\/person\\\/f785ba3ecc599133e65ab6138042a3e4\"},\"description\":\"What is the namespace in Python ? - In python a namespace is a system that has a unique name for each and every object.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-the-namespace-in-python\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/python\\\/what-is-the-namespace-in-python\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/types-of-namespaces.png\",\"contentUrl\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/types-of-namespaces.png\",\"width\":748,\"height\":663},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#website\",\"url\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#\\\/schema\\\/person\\\/f785ba3ecc599133e65ab6138042a3e4\",\"name\":\"webmaster\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"caption\":\"webmaster\"},\"sameAs\":[\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\"],\"url\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/author\\\/webmaster\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is the namespace in Python ? - Python NameSpace - Wikitechy","description":"What is the namespace in Python ? - In python a namespace is a system that has a unique name for each and every object.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/","og_locale":"en_US","og_type":"article","og_title":"What is the namespace in Python ? - Python NameSpace - Wikitechy","og_description":"What is the namespace in Python ? - In python a namespace is a system that has a unique name for each and every object.","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/","og_site_name":"Wikitechy","article_published_time":"2022-08-16T10:15:34+00:00","og_image":[{"url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/types-of-namespaces.png","type":"","width":"","height":""}],"author":"webmaster","twitter_card":"summary_large_image","twitter_misc":{"Written by":"webmaster","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/#article","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/"},"author":{"name":"webmaster","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"headline":"What is the namespace in Python ?","datePublished":"2022-08-16T10:15:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/"},"wordCount":295,"commentCount":0,"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/types-of-namespaces.png","keywords":["enclosing namespace in python","example for namespace in python","explain namespaces in python","namespace in python","namespace in python hackerrank solution","order of namespace in python","python list namespaces","python namespace object","types of namespaces in python","use of namespace in python","what is global namespace in python","what is namespace in c++ with example","what is namespace in python with example","what is scope in python","what is the default namespace a program will run in python","what is the namespace in python","what is the order of namespace in which python looks for an identifier","what is the use of namespace in python"],"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/","name":"What is the namespace in Python ? - Python NameSpace - Wikitechy","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/types-of-namespaces.png","datePublished":"2022-08-16T10:15:34+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"description":"What is the namespace in Python ? - In python a namespace is a system that has a unique name for each and every object.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-the-namespace-in-python\/#primaryimage","url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/types-of-namespaces.png","contentUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/types-of-namespaces.png","width":748,"height":663},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4","name":"webmaster","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","caption":"webmaster"},"sameAs":["https:\/\/www.wikitechy.com\/interview-questions"],"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4690","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=4690"}],"version-history":[{"count":1,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4690\/revisions"}],"predecessor-version":[{"id":4693,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4690\/revisions\/4693"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=4690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=4690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=4690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}