[Zope] How to import a basic class in Script (Python)

Dieter Maurer dieter at handshake.de
Wed Jul 18 15:18:12 EDT 2007


Tudor Gabriel wrote at 2007-7-18 12:26 +0300:
> ...
>now let's suppose all the files (all the py and zpt files) are in the
>same directory:Library
>
>in search_books_py i tried importing the book class in this ways:
>
>from book_py import *
>from Library.book_py import *
>from here.book_py import *
>from container.book_py import *

The "import *" is not very good style:

  You do not see where names come from -- this may drastically
  affect readability of your code

  A later "import *" may accidentally override names imported
  in a previous "import". I have seen cases where considerable
  analysis time was caused by such constructs.

If at all, you should have at most a single "import *" -- the first
import.

Your names look funny. Why do they all end in "_py"?

Your Zope folders cannot be reached by the Python interpreter.
You cannot import from objects places in Zope's Web hiearachy.



-- 
Dieter


More information about the Zope mailing list