Sometimes you want to ensure that only one copy of a script can be run at time. Windows provides a facility called a mutex and you can use it to prevent multiple instances.
To create the mutex, all I have to do is
varname = GetMutex()
If the mutex already exists then IsRunning()
will return True so the line
if (myapp := GetMutex()).IsRunning():
both creates the mutex (maybe) and tests if the app is already running. Note this this uses the walrus (:=) works only in Python 3.8.2 or newer.