how do I know to what module an object belongs?

Michal Wallace (sabren) sabren at manifestation.com
Thu Apr 13 21:38:44 EDT 2000


Hey All,

   I'm not having much luck with the Python docs tonight. :)

   I'm building a wrapper around the Python DB-API. Each module that
implements the API is supposed to define a bunch of objects like
STRING, DATE, BINARY, etc, so you can tell what kind of field you're
dealing with. But those values change from module to module.. Eg, the
XYZ database module, might use strings, whereas the ABC module might
use numeric codes. So basically, I need to test for something like:

   if fieldtype == somemodule.STRING:
       pass

   Now, because this is an abstraction layer, I don't know which module
I'm dealing with. The user creates a connection object from whatever
module they want, and then passes just that connection object to my
class.

   I know I can just as easily have them pass a reference to the
module along with it, but I'd be happier if I could just look at the
connection object and know which module it came from. Can I do this?

Cheers,

- Michal
-------------------------------------------------------------------------
http://www.manifestation.com/         http://www.linkwatcher.com/metalog/
-------------------------------------------------------------------------





More information about the Python-list mailing list