I began to learn Python a few hours ago and I was wondering if it's possible to execute a script which I wrote in the BBEdit text editor in the Python Shell just with a click.
There are options to run it in the Mac Terminal and in the Debugger but being able to execute it directly would make learning a lot easier.
The tab used for executing/debugging code in BBEdit
You can run the current script (the script contained in the front window) just using the BBEdit command "Run", from the "#!" menu (this menu is sometimes called "shebang" menu) or by pressing CMD – R.
This command runs the script, and prints the output in a new BBEdit window.
Make sure to add the following code at the very first line of your script:
#!/usr/bin/env python
or in general
#!path/to/python [arguments]
This makes sure that the python interpreter is called, to run your script. Another option is to use the "Run in terminal" command, from the same "#!" menu. In this case, a new terminal window is created, and the output of your script will be sent there.
If you want BBEdit to save the unsaved changes in the script before launching it, make sure to read this other Stack Exchange page: automatic save before “Run in Terminal” in BBEdit
I think PyCharm make things more easy for you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With