How to have Pycharm always run "Current File"

Is that what you’re looking for ?

Also, a good practice in Python is to have the code you want to execute protected by an
if __name__ == "__main__": statement. See the reference documentation for rationale and further details:

When you do so, PyCharm will automatically add a run button on the left of the file editor, on which you can click to run the current file (see my screenshot below). I find it quite convenient !

image

1 Like