Selective importing and package dependencies

David Pratt fairwinds.dp at gmail.com
Sun Sep 28 10:10:25 EDT 2008


Hi. I am in the midst of preparing a package to convert between  
various schemas including orms. The issue is I don't want django,  
slqalchemy, storm, rdflib etc. as hard dependencies of the package.  
Each module is a schema to schema conversion. As an example, I have  
imports for sqlalchemy with classes and methods that use them.

from sqlalchemy.util import OrderedDict
from sqlalchemy import types as rdbtype
import sqlalchemy as sa

I have my own ideas about how I might do this but looking for  
recommendations from others how they would handle this so the result  
would be:

1. no hard dependencies on any of these other packages
2. load the module without failure.
3. import the dependent package if available to perform the conversion

Many thanks
David



More information about the Python-list mailing list