Skip to content

Commit ddfecda

Browse files
committed
[viewcfg] Prevent execution when importing
In order to prevent the Python interpreter from running code that is meant to be executed directly, the convention is to check the context in which the code is being interpreted. Add a check for the context stored in the `__name__` variable, and only execute the viewcfg script if it is being run as a command-line script (that is, `__main__`).
1 parent 209bc41 commit ddfecda

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

utils/viewcfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,5 @@ def main():
170170

171171
subprocess.call(["open", fileName])
172172

173-
main()
174-
173+
if __name__ == '__main__':
174+
main()

0 commit comments

Comments
 (0)