Namespace
Пространство имён
A namespace groups names so that different functions, classes, or other items can share a name without being confused. An extra qualifier, such as `billing` in `billing::Report`, tells the language which one you mean.
Also known as: модуль, package
Why namespaces matter
Suppose a Python program uses two libraries that both provide a function called parse. One reads configuration files; the other reads dates. If you keep the module names in the calls, config_parser.parse(...) and date_parser.parse(...) tell both Python and the reader which function you want. Neither library needs to rename its function just because the other chose the same name.
How names are resolved
A namespace is a set of names and the things they refer to, such as functions, types, and values. When you write a bare name such as parse, the language looks it up according to its own rules. In Python, a bare name inside a function can refer to a local variable, a name in an enclosing function, a module global, or a built-in. With a reference such as date_parser.parse, Python first resolves date_parser, then looks up parse on that module. Other languages use different syntax: a C++ reference might look like dates::parse.
Example: two parse functions in Python
import csv
import json
csv_rows = csv.reader(["Ava,42"])
json_row = json.loads('["Ava", 42]')
Both calls show where the operation comes from. A collision appears if you choose the same local alias for both: from csv import reader as parse followed by from json import loads as parse. The second import rebinds parse, so parse(...) now calls json.loads. Module-qualified calls avoid that problem and make the expected input format easier to see.
Namespace, scope, module, and package
A namespace tells you what a name refers to within a particular group. Scope tells you where in the code a binding can be found by its bare name. For example, a local variable called json can shadow the module name inside a function. The module's own namespace hasn't changed; it is the meaning of the bare name json inside that function that has changed.
Modules and packages can provide namespaces, but the terms are not interchangeable. A Python module has its own namespace, and a Python package can contain modules and subpackages. A Java package contributes to a class's qualified name. In C++, several source files can contribute declarations to the same namespace. Namespacing alone does not make code private or enforce an access boundary.
What interviewers ask
You may be given two imports with the same short name and asked what a subsequent reference means. Explain the rules for the language in question: Python can rebind the name, while a C++ lookup can become ambiguous if two using namespace directives make matching names visible. Then show how keeping the qualifier or using distinct aliases makes the reference clear.