On Fri, Sep 19, 2008 at 10:14 AM, Ron Adam email@example.com wrote:
Carl Johnson wrote:
Is there a good reason why I can't do something like:
import mypackage import mymodule
x = mypackage(arg, kwarg) y = mymodule + 3
and other methods, etc. using the __special__ methods.
Also, wouldn't it be cool if modules/packages could have metaclass-like handlers…
I'm sure there's a good reason why this is just crazy talk implementation-wise, but I'd like to hear what it is. Python has merged types and classes, why not merging in packages and modules, too?
Would these __special__ methods be seperate files like __init__.py is for packages?
I don't believe that was his intent.
Generally though, this isn't difficult to do: override __import__. The ultimate question, however, is whether or not this improves code quality, readability, or maintainability. I don't believe it would, so aside from a "purist" approach to unifying, it fails in the face of practicality.