On Wed, Aug 29, 2012 at 11:37 AM, John Goodleaf <[email protected]> wrote: > I don't generally define things in __init__.py, but there are reasons why > you might do so. If you really want to initialize a number of things and > make them broadly available "automatically," it's handy. Some codebases > (django) do this a lot. So the takeaway, I think, should be "don't define > anything in __init__.py unless you have a specific reason for doing that."
I think the only thing that might get clobbered is names that match sub-module names -- so don't do that! People put a whole pile of stuff in __init__.py files -- personally I don't, but I do sometimes put: from module import this, that, the_other so that there is stuff in the package name space. sometimes even: from module import * (which is the ONLY way I"d ever use import *) "I think the real moral here is don't try to use a module you haven't imported yet" (though I realize this is a boiled-down example, and there may have been a rational reason in the original) -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [email protected]
