So apparently when people the time to write something down they wrote it down for a reason. I happened to have missed this simple fact recently when I was working on some Python scripts. I was trying to separate the scripts into different folders based on what they did. Simple enough, but then I ran into the issue of certain scripts needing to go around folder boundries. Of course, Python supports this feature using it’s import system.
This is where my trouble was. I was reading the article about how import works from the standard Python docs. So I read as much as I thought I needed and skipped over, what I thought at the time, to be unimportant. As it turns out the ability to do relative imports using ‘..’ is a feature of only Python 2.5 *sigh*. Alright, so I could have just installed Python 2.5, but I didn’t want to limit this code to running on Python 2.5 for no good reason. So I went back and changed the code to using absolute imports which took around 30 minutes because there were a decent number of files to play with.
So how did I miss this in the documentation? Well I managed to skim over the part which mentions this is only for Python 2.5 (I blame myself for this, btw). I take this as a lesson to pay closer attention when reading documentation. It may have taken me an extra 5 or 10 minutes to read all the documentation about imports and Python… but I will would have saved half an hour of my time if I had taken the extra effort 🙂