Python modules appear outside

One strange thing happened to me today. I tried to find the appengine and Django application at www.shell.appspot.com when I entered    dir(django) o / p I got

['VERSION', '__builtins__', '__doc__', '__file__', '__name__', '__path__', 'conf', 'core', 'template', 'utils']

but still i tried

from django import forms

and it worked to my surprise, while no trance of it was in o / p dir(). Out of curiosity, I entered again dir(django) and it turned out that

['VERSION', '__builtins__', '__doc__', '__file__', '__name__', '__path__', 'conf', 'core', 'forms', 'oldforms', 'template', 'utils']

Pay attention to the form element here. Can someone explain to me where these forms come from?

+3
source share
1 answer

from package import module ( ) package/module.py ( package/__init__.py, ) 'module' (t21) ). , dir(package) 'module' , .

(), ( dir!)) , - " ", ( paren dir).

+8

Source: https://habr.com/ru/post/1751852/


All Articles