Alternatively, you can directly access the LocalPath string form as an attribute.
os.path.join(tmpdir.strpath, 'my_test_file.txt')
I used to think that using attribute access means that you did not add the object to the string, thereby being more efficient, but I think I am mistaken in this assumption, but I like this style a little better, it's easier to write IMHO
source share