Skip to content

Instantly share code, notes, and snippets.

@halfak
Created January 14, 2015 20:29
Show Gist options
  • Save halfak/2a62b76b348981c28104 to your computer and use it in GitHub Desktop.
Save halfak/2a62b76b348981c28104 to your computer and use it in GitHub Desktop.
>>> import revscores
>>> dir(revscores)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
>>> from revscores import languages
>>> dir(languages)
['Language', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'english', 'language', 'portuguese']
Notice that the first "dir()" doesn't list out langauge. This is because language is not imported by default.
But when we run dir() on language, we can see "english", "portuguese" and "language". This is because these modules are imported by default.
>>> from revscores import languages
>>> languages.english
<revscores.languages.language.Language object at 0x7f69cb053ba8>
So, we can just access "english" directly from the "languages" module. But we can't do the same from revscores to languages.
>>> import revscores
>>> revscores.languages
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'languages'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment