Re: Python-Dev digest, Vol 1 #2276 - 14 msgs
I asked about publishing a module & submodules in one .py file, and showed an implementation. Guido responded:
I think it's much better to split it up in multiple files than to use all those hacks. Those hacks are hard to understand for someone trying to read the code.
I agree - I don't like the look of that code for user-level code. However, to me the complexity was that I had to show the implementation (and the dynamic "getMethods" call instead of explicitly listing methods to publish). If the 'imp' module had a 'publish_module' method that created a module (with an optional dictionary?) & registered it in sys.modules, client code becomes very simple, clear, and can be very explicit: assertions = imp.publish_module( __name__ + ".assertions" ) _a = Assertions() assertions.failUnless = _a.failUnless # ... Is that more pleasant, or is the whole idea of organizing portions of a single file into submodules unacceptable? kb
Is that more pleasant, or is the whole idea of organizing portions of a single file into submodules unacceptable?
There are already various ways to create sub-namespaces in a module, e.g. classes or functions. I really don't see the point of having submodules. --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (2)
-
Guido van Rossum
-
Kevin Butler