Module, Package

Ben Finney ben+python at benfinney.id.au
Mon May 7 23:00:27 EDT 2018


Sharan Basappa <sharan.basappa at gmail.com> writes:

> One question. So, we can import the entire package or just a module in
> a given package. Is this correct?

Each time you ‘import foo’, you are getting a module.

> For example,
> import nltk

That results in a module object, and you can use the name ‘nltk’ to
reference that module.

> import nltk.stem

That results in a different module object, and you can use the name
‘nltk.stem’ (which is the name ‘stem’ in the namespace ‘nltk’) to
reference that module.

See the Python documentation for a good description of the import system
<URL:https://docs.python.org/3/reference/import.html>.

-- 
 \          “If we could change ourselves, the tendencies in the world |
  `\  would also change.” —Mohandas K. Gandhi, _Collected Works_, 1913 |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list