Why Oh Why Do Some Coders Try to Get Tricky?
I've run into this a lot in at least a few languages - Java and Python. The coder thinks he's saving something by saying:
import java.util.Date; import java.util.Vector; import java.util.Stack;
as opposed to simply saying:
import java.util.*;
I mean really... what are we saving here? Nothing. Exactly nothing. The reading of a file? No... it's still got to read what it reads for the three classes from the one jar file. Microseconds on the compile - maybe. But what have you done? You've forced all additional developers to enumerate all classes they are using. Why? Is it really that important?
It gets worse in Python. I ran into the following code:
import logging.config, os, sys
where the normal developer would say:
import logging, os, sys
Can't imagine we've gained anything by just loading the config if we're really do any logging, chances are we're going to actually log. But what I found out today is that this can cause a ton of trouble in systems with the thread package built-in and using the dummy_thread.py stub.
For these guys, you really need to do the following:
try: import thread except ImportError: import dummy_thread as thread
and in doing this we are able to use the thread package as if it always existed - even when it doesn't. Decent. And the logging package does this - so long as you import it properly. If you try to, oh, I don't know... say import just the logging.config package this isn't done and then all of a sudden the dummy_thread.py isn't pulled into play and you get import errors in the python logging libraries.
Argh!
So I have to ask around and see who might have done this and for what reason. I don't want to make a change that will break something just to get something else to work. We need to have everything working, and if that means we need to put more work into this guy, then so be it, but I'm very clear that this is code written here and not a part of the core Python code.
It's something I'm going to have to deal with on this little project. It's not fun, but it's what I have to do.