understanding nltk with python
Question: My nltk data is `~/nltk_data/corpora/words/(en,en-basic,README)`

According to `__init__.py` inside `~/lib/python2.7/site-packages/nltk/corpus`,
to read a list of the words in the Brown Corpus, use
`nltk.corpus.brown.words()`:

    
    
    from nltk.corpus import brown
    print brown.words()
    ['The', 'Fulton', 'County', 'Grand', 'Jury', 'said', ...]
    

This `__init__.py` has

    
    
    words = LazyCorpusLoader(
        'words', WordListCorpusReader, r'(?!README|\.).*')
    

  1. So when I write `from nltk.corpus import words`, am I importing the 'words' function from `__init__.py` which resides in directory `python2.7/site-packages/nltk/corpus`?

  2. Also why does this happen:
    
         import nltk.corpus.words
     ImportError: No module named words
     from nltk.copus import words
     # WORKS FINE
    

  3. The "brown" corpus resides inside `~/nltk_data/corpora` (and not in nltk/corpus). So why does this command work?
    
        from nltk.corpus import brown
    

Shouldn't it be this?

    
        from nltk_data.corpora import brown
    


Answer: Re. point 2: You can import either a module (`import module.submodule`), or an
object from a module (`from module.submodule import variable`). While you can
treat a module as a variable, because it actually is a variable in that scope
(`from module import submodule`), it doesn't work the other way. That's why
when you try doing `import module.submodule.variable`, it fails.

Re. point 3: Depends on what `nltk.corpus` does. Maybe it searches/loads the
`nltk_data` for you automatically.

