Where is os.path.join(os.path.dirname(__file__), 'data') in Linux/Windows?

python

Solution

`os.path.dirname` gives you the directory its argument is in, and `os.path.join` appends a file or directory to the given directory.

`os.path` provides you with a platform-independent way to modify file and directory paths, making use of the appropriate types of slashes.

So yes, this will create a 'data' directory (if it doesn't already exist) within the same directory as the source file from which this code is run.

Problem

Where is the folder the following code is creating on different operating systems? ``` data_dir = os.path.join(os.path.dirname(__file__), 'data') if not os.path.exists(data_dir): import generate_data os.mkdir(data_dir) ``` Is it `/path/to/file/data`?

Original source