what is dot notation of referring
to Object inside a module?
Answers
Answered by
8
ello!!
Once you import a module (like sys or anything), the dot-notation may then refer to anything it contains. You could also import a 'package' contains modules, classes, methods in classes, functions in modules, etc.
>>> import sys
>>> type(sys)
<class 'module'>
>>> sys.stderr
<_io.TextIOWrapper name='<stderr>' mode='w' encoding='cp437'>
>>> type(sys.stderr)
<class '_io.TextIOWrapper'>
>>> type(sys.stderr.write)
<class 'builtin_function_or_method'>
>>>
It's meant to be generic sort-of-attribute access where each thing inside another is accessed via the dot, as if it was an attribute of that object, which it is.
Similar questions
English,
6 months ago
Computer Science,
6 months ago
Math,
6 months ago
Math,
1 year ago
Social Sciences,
1 year ago
Math,
1 year ago
Hindi,
1 year ago