0

This is an extract from a textbook :

When using the import modulename form of import, the namespace of the imported module becomes available to , but not part of,the importing module.

I am not able to understand ,What exactly is namespace and what do they mean by ''namespace becomes available to but not part of importing module''?

  • Does this answer your question? [importing with \* (asterisk) versus as a namespace in python](https://stackoverflow.com/questions/26767300/importing-with-asterisk-versus-as-a-namespace-in-python) – Gino Mempin Dec 21 '20 at 11:55

1 Answers1

0

Lets say you are doing

import os 

you can now access members of os, for example

os.path

but you cant access path directly as it's not in your namespace, it's in the os namespace.
It's the difference between

import os 

and

from os import * 

(the latter will import everything into your namespace and should generally be avoided to not accidentally overwrite methods)

Nullman
  • 4,179
  • 2
  • 14
  • 30