[Tutor] Still Trying to Understand GAE

wesley chun wescpy at gmail.com
Sun Sep 13 20:49:41 CEST 2009


hi Giorgio,

welcome to Python (whether directly or from GAE!) :-) my comments below.


> with import i can import modules or single functions. And this is ok.

not quite true. regardless of whether you use import or from-import,
you're *always* importing (and loading) modules or packages in their
entirety.

now, whether you have *access* to "entire" modules/packages or
individual attributes (functions, classes, or standard data), is
another matter -- usually this is a result of using from-import.

also, the difference between importing and loading is that loading
only happens the first time you import a module/package. (if you do it
more than once, e.g., module A imports B and C and module B also
imports C, the import of C happens twice but the loading happens only
once.


> if i use "import
> google" it also imports all subdirectories. And i can't understand
> wiìhy it does so.

it imports all sub*packages*. don't think directories because the
import mechanism doesn't work this way. this is likely because there
are __init__.py files in those subdirectories. another possibility is
that there are non-empty __init__.py files that do the imports of
things that you're not expecting.

hope this helps!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
"Python Fundamentals", Prentice Hall, (c)2009
    http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com


More information about the Tutor mailing list