From: Luke O. <lu...@me...> - 2003-04-29 19:43:07
|
> from MyDB import Person > > peep = Person(1) > > for cat in peep.cats: # error because Cat has not been imported. > > print cat > > Problem solved, because Cat has been imported through the package. > > Nick Ugh. Certainly this works.. I'm initially shying away from doing full imports like this for performance reasons, but I suppose it's a one-time cost per interpreter. Also, I could create functional partitions of some of these large databases where this concerns me (from MyDB.ProductStuff import ....). Hmm, ok. (The other part that bothers me is maintaining the list of DB Objects in both the directory and in the __init__, but I suppose I can solve that with an "import everything in this dir" script I have lying around, in __init__.py instead of explicit imports.) - Luke |