Matthew Wilson <m...@tplus1.com> writes: > Today I realized that I'm hardcoding paths in my app. They are > relative paths based on os.getcwd(), but at some point, I'll be > running scripts that use this code, these open(...) calls will fail.
The conventional solution to this is: * Read configuration settings, whether directory paths or anything else, from a configuration file of declarative options. * Have the program read that configuration file from one location (or a small number of locations), and make those locations well-known in the documentation of the program. Python's standard library has the ‘configparser’ module, which is one possible implementation of this. -- \ “I used to be an airline pilot. I got fired because I kept | `\ locking the keys in the plane. They caught me on an 80 foot | _o__) stepladder with a coathanger.” —Steven Wright | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list