[Python-Dev] Package Style Guide

Peter Funk pf@artcom-gmbh.de
Thu, 8 Jun 2000 14:28:11 +0200 (MEST)


Hi Greg,

[me]
> > -->  IMO 'from ... import ...' is EVIL and its use should be banned!  <--

[Greg Stein]:
> You are being overly strict here. I use this all the time:
> 
> from module import submodule
> ...
> submodule.Class()
> 
> or even
> 
> from module.submodule import subsub
> ...
> subsub.Blargle()

Okay.  Later in my rant I wrote:

< Well: at least if people use 'from' to import arbitrary objects and
< classes.  Using 'from package.subpackage import module' is an idiom,
< with which I can live with comfortably.

[Greg Stein]:
> In other words, "from package import module" is a Fine Thing. It can
> simplify your code without hiding where the symbols come from.

Yes, you are right.

But if you put the facade pattern[*] into use within such packages,
this will even simplify your live, if you later have to redesign
the internal substructure of your package.

[*] Design patterns and especially the "facade pattern" were AFAIK 
    introduced in the so called "Gang of four" book: "Design Patterns -
    Elements of Reusable Object-Oriented Software", Addison Wesley, 1995.

    The somewhat similar "whole part" design pattern is discussed 
    in the book "A System of Patterns" written by Buschmann, Meunier, 
    Rohnert, Sommerlad, Stal; published by John Wiley & Sons, New York; 1996; 
    ISBN 0 471 95869 7

> In general, I agree with you: importing symbols from a module into your
> namespace is a Bad Thing.

Fine.  Consensus gives a warm and fuzzy feeling. ;-)

Regards, Peter