On Mon, May 7, 2018 at 1:05 AM, George Fischhof email@example.com wrote:
On Sun, May 6, 2018, 1:54 AM Yuval Greenfield firstname.lastname@example.org wrote:
I often need to reference a script's current directory. I end up writing:
import os SRC_DIR = os.path.dirname(__file__)
I would give +1 for __dirname__
Something to keep in mind: making this available to every module, whether it's wanted or not, means that the Python interpreter has to prepare that just in case it's wanted. That's extra work as part of setting up a module. Which, in turn, means it's extra work for EVERY import, and consequently, slower Python startup. It might only be a small slowdown, but it's also an extremely small benefit.