[Baypiggies] Suggestions?

Aahz aahz at pythoncraft.com
Sat Oct 31 00:16:24 CET 2009


On Fri, Oct 30, 2009, Glen Jarvis wrote:
> 
> In my backup.py file, I have the following imports (organized in groups per
> PEP-8; http://www.python.org/dev/peps/pep-0008/). However, one of our hosts
> intentionally doesn't have psycopg2 installed. How do most deal with the
> conditional import, while still keeping the imports grouped at the top of
> the file? Or, better yet, how do you deal with this? It's very tempting to
> break convention and only import psycopg2 module in the functions that need
> it. That seems extreme for just one node in our system, however.

Why not just break the psycopg2 stuff into a separate module that doesn't
get used on one machine?  Otherwise, the try/except is what I'd do.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"You could make Eskimos emigrate to the Sahara by vigorously arguing --
at hundreds of screens' length -- for the wonder, beauty, and utility of
snow."  --PNH to rb in r.a.sf.f


More information about the Baypiggies mailing list