[Tutor] Classes + inheritance

Tim Peters tim_one@email.msn.com
Sat, 17 Apr 1999 02:31:05 -0400


[Arne Mueller]
> ...
> Does a class always look for another class it uses in the module where
> it's defined?

Yes or no, depending on what you mean by each of those words <wink>.

The general rule has no exceptions:  every name in every context is first
looked up in the local scope; if not found there, then in the global scope;
if not found there, in the builtin scope; and if not found there either
NameError is raised.  "The global scope" is usally "the module" containing
the code containing the name being looked up.  There is never any magical
leaking of names across module boundaries; Python's "global" is much more
like C's file-scope static than like C's extern.

scoped-out-ly y'rs  - tim