import tempfile import mailbox import glob # Current behavior won't create subdir when dir exists with tempfile.TemporaryDirectory() as d: m = mailbox.Maildir(d) print(glob.glob(d + '/*')) # Current behavior will create dir and subdir when dir isn't exists path = '/tmp/dir_not_exist' m = mailbox.Maildir('/tmp/dir_not_exist') print(glob.glob(path + '/*'))