What is the best way to edit a Python file in command line on mac?
Use any of the standard editors: vim, emacs, nano.
I like to use the nano editor, just type nano filename.py and you are good to go!
Not sure whether this is what you’re going for, but you can also open a file in a GUI app from the command line. See this StackOverflow answer from a few years back.
I prefer vi or vim. vi is the default editor to most linux system and also mac. So you don’t have to worry about installing some other editor which may require root access in some systems.
Getting started with vi is a bit of a learning curve if you are coming from GUI IDE but it should not be too hard. Here is the link to quick start guide: https://www.cs.colostate.edu/helpdocs/vi.html
The official documentation is verbose but should help : http://linuxfocus.org/~guido/vi/vimbook-OPL.pdf
You can also get vim’s macros and other flags with vi --help command in terminal
All of the above are good options especially when in a pinch but when working with Python I find it hard to diagnose certain issues with standard text editors. GUI based Code Editors like Visual Studio Code allow me to see things like the amount of tabs and spaces and will point out minor errors in your code to help you debug. As mentioned above they can be opened via command line but are entirely GUI-based.