Module Structure/Import Design Problem
steve at holdenweb.com
Sat Nov 22 16:20:54 CET 2008
Stef Mientki wrote:
> Steve Holden wrote:
>> Stef Mientki wrote:
>>> Gabriel Genellina wrote:
>>> Sorry I don't understand all that pep-talk (I'm not a programmer ;-)
>> And I'm not a plumber. The difference between us is that I don't write
>> blogs telling people how to lay out and connect their pipework.
>> PS: Q: What's the difference between God and a doctor?
>> A: God doesn't think she's a doctor
> Probably this a a local disease after all,
> as only me and a couple of other non-programmers in my surrounding seems
> to have the same view on imports as me.
> Let me try to explain my point of view.
> Undoubtable the import statement gives enormous functionality and
> flexibility to programmers.
> But for non-programmers the import statement is of no value whatsoever,
> and it's just a necessary evil.
> Above that, the import statement is (for non programmers) one of the
> most difficult to understand parts of Python.
> On the other hand, why do need Lutz and Ascher (which might not be the
> best book) over 50 pages to explain imports and packages ?
> Delphi, known as an "old language", has already automated imports for
> more than 15 years.
> I would love to see a cookbook recipe (of at most 2 pages) , written by
> of how to use imports in the right way. Or even better an automated
> import mechanism.
> But as it looks that only a few people have the same problem as me,
> it has no value to pay any further attention to this issue.
I don't think the existing (2.6) documentation on packages is at all
satisfactory, consisting as it does of a single paragraph:
Hierarchical module names: when the module names contains one or more
dots, the module search path is carried out differently. The sequence of
identifiers up to the last dot is used to find a “package”; the final
identifier is then searched inside the package. A package is generally a
subdirectory of a directory on sys.path that has a file __init__.py.
Brett Cannon, a fairly active core developer, gives interesting talks
about the way the import mechanism is broken, and has plans to
eventually include a replacement implemented entirely in Python. When
that happens, we might expect the documentation to improve, but I am
afraid that in open source it has to be an itch that someone needs to
scratch, and it seems like so far nobody is itching badly enough.
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list