[Qgis-user] quit() and exit()
Raymond Nijssen
r.nijssen at terglobo.nl
Mon May 2 09:17:05 PDT 2022
Put your code in a main() function and use return to leave the function?
On 02-05-2022 18:06, Stephen Sacks via Qgis-user wrote:
> I would like to terminate a Python script gracefully. Both quit() and
> exit() not only abort the script but end the entire QGIS app. For
> example, if a file I want to read doesn't exist, the following four
> lines of code terminate QGIS:
>
> filePath = Path(fName)
> if not filePath.is_file():
> print ('Unable to find file ', fName)
> exit()
>
> Substituting quit() for exit() doesn't help. I could omit both, and
> put all of the remaining code under an "else" but that seems rather clunky.
> Any suggestions would be welcome.
>
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
More information about the Qgis-user
mailing list