Computer Science, asked by deep4637, 1 year ago

what is dot notation of referring
to Object inside a module?​

Answers

Answered by priya9531
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