Sublime Forum

Open_file() but only if the file exists

#1

Is there a way to get open_file not to open a new view if the requested file is invalid?

window.open_file("bogusPath", sublime.FORCE_GROUP, 0)

This opens a buffer named “bogusPath”. I just want it to do nothing.

0 Likes

#2
import os

if os.path.isfile("bogusPath"):
    window.open_file("bogusPath")
1 Like

#3

Yeah, but that has a race condition

0 Likes