Go Straight to Content

What I'll Be Ranting About

Good development practices bring us quality code, confident systems, and missed launch windows. When do you refactor and when do you factor in the passing time? As engineers we need to design what is possible and capable. As programmers we need to turn imagination into reality without a physical product. As developers we need to bridge the gab between that engineered vision and the end product.

I also blog more personally over at my tumblr page.

I am available for small contracts, consultations, tutoring, and other development services. My "skills" as a technical writer are also available. If you've got anything you'd like to talk to me about or for me to see, drop me a line.

Saturday, March 03, 2007

The Implied Module Path

We all know there is an implied path to import from for the main module, but it seems a few people get mixed about the details of how this works. In particular, it seems that this path is being confused for the current working directory. Here is a little note to help remember the distinction.

  • Any module implicitly can import packages and modules in the same directory its file resides in, which is os.path.dirname(the_module.__file__)
  • Often you run a script, when starting out, from its own directory, so that this implied path is the current working directory. This fact is purely a coincidence.
The result boils down simply to understanding that any import can be relative to the module it appears in, and if you run a local (not system-wide available) script, that just happens to be your current directory, by coincidence.

Blog Archive