Encapsulation in Python

Gregory Ewing greg.ewing at canterbury.ac.nz
Sun Mar 13 19:35:25 EDT 2016


Rick Johnson wrote:
> Sure, that's reliable in most cases, but your argument
> assumes that the actual source code for the symbol exists in
> the module from which it was imported, when it could just as
> well exist N-levels below that that module, due to chained
> imports.

Unless the module is doing something obscure, you can
still find it by following the chain of imports. And
since Python culture encourages rather shallow
module nesting trees, the chain is usually fairly
short.

True, it's not *always* that easy, but in the vast
majority of cases it is. The situation is certainly
much better than what you have in e.g. a large C
project, where you get *no idea* where a particular
symbol may have come from by inspecting the source.

-- 
Greg



More information about the Python-list mailing list