I have a text buffer that is loaded from an external file. In that same text buffer I need to write code that imports some functions from another file in the same directory as the one in the text buffer.
- Hardcoding that path in the source is unsuitable because the file may live in different directories on different users' machines.
- Command-line arguments seem like a a horrid Rube Goldberg kludge and a horrible user experience.
- a file selection dialog is also poor user experience.
Java has a mechanism similar to what I want using class.getResource(relPath) (imagine if tomcat gave you a file selection dialog box when it needed to load the Spanish translations for localized string resources)
What is the best python technique to accomplish this?