On Wed, Apr 29, 2009 at 03:06:13PM -0700, Scott David Daniels wrote: > You did not answer the question above, and I think the answer is the root > of your misunderstanding. A class and a module are _not_the_same_thing_. > sys is not a package, it is a module. >>> Just because you put a class inside a module, does not mean >>> that class magically does something by virtue of having the >>> same name as the module. >>> >>> A module is a namespace to hold classes, functions, etc.... >>> A package is a namespace to hold modules (possibly more). >>> >>> I don't understand why you don't use files like: >>> >>> VLMLegacy/ >>> __init__.py >>> Reader.py >>> VLM4997.py >>> WINGTL.py > Unlike Java, we are free to have several things in a module: > several classes, several functions, several constants....
These modules would grow to be hundreds of pages long and a difficult to deal with to debug a problem related to one obscure system without looking at (or potentially screwing up) any of the others. I prefer one class per module. This gets more into philosophy, but I figure any function or method that does not fit on one page is too big; and any source file that is more than 20 pages long should be broken in half. I like my modules in the 5-10 page size range, including the embedded Unix ManPages and the cvs history. But that's just my house style. > Well, "VLM4997" is a _string_, and it has no attributes (nor methods) > named "Header", "Plan", or "Conditions." And "type" is a perfectly awful > name for a variable, since it hides the builtin named type. You seem to > confuse names, files, and classes defined in files (at least in your > writing). Actually I'm not. I am simply trying to use a pseudo code to explain roughly what is going on. There will be a string that selects what the set of classes are to be used on any given iteration and it will be used to generate the name of the class and/or name of the module where it is to be found. I'm an old ObjC hacker. I often put the class or method in a variable and do the bindings at runtime. I am already doing some of that sort of thing in this system with the method names and it works nicely. The point I take away from this is that packages and modules have dotted names, but Classes do not and there is no way to do exactly what I wanted to do. The dot syntax would have been quite nice (I quite like the "::" syntax in Perl) and would have made the code much clearer. The way you suggested with a 'typename_classname' generated using a from/import statement will just have to suffice.
signature.asc
Description: Digital signature
-- http://mail.python.org/mailman/listinfo/python-list