[Zope] Styles of import in Zope (2 and 3)

Chris McDonough chrism at plope.com
Sat Aug 30 21:04:10 EDT 2008


One goal to shoot for when you do imports is to be able to remove an imported
name by deleting a line as opposed to editing one (it makes reading diffs a bit
easier).  E.g. instead of:

  from foo import one, two, three

I usually either do:

  import foo
  foo.one

Or:

  from foo import one
  from foo import two
  from foo import three

Either way makes diffs cleaner.

One thing I always avoid is "from foo import *".

- C


Marco Bizzarri wrote:
> Please, feel free to point me to The Fine Manual to read, if this has
> been answered and written many times.
> 
> After reading the article "Importing Python Modules"
> (http://effbot.org/zone/import-confusion.htm), I had many doubts about
> the style to use in imports in Zope 2 and Zope 3.
> 
> The article points to a style which should be:
> 
> from package.subpackage import module
> 
> and then use
> 
> module.MyClass
> 
> Is this the recomended style in Zope2/3 also?
> 
> Regards
> Marco
> 



More information about the Zope mailing list