thomblake comments on PSA: Learn to code - Less Wrong

34 Post author: John_Maxwell_IV 25 May 2012 06:50PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (77)

You are viewing a single comment's thread. Show more comments above.

Comment author: John_Maxwell_IV 26 May 2012 07:58:13PM *  5 points [-]

Typically people use a keyboard shortcut to save, which makes it less painful.

For running your program, try typing

python yourprogram.py

from your console/terminal/whatever after having navigated (by typing "cd directoryname" and "dir"/"ls" repeatedly) to the directory where your program is. After having typed the execution command once, you can just push the up arrow on your keyword to restore that command on the command line. So under ideal conditions, executing your program should consist of four actions: pushing a keyboard shortcut to save, switching to a terminal window, pushing the up arrow key, and pushing enter.

Probably the instructions I just gave you will be hard to follow because they are awfully compressed and I don't know your platform. So feel free to tell me if you run into a problem. You may wish to make an explicit effort to learn the command line; I believe there is a Hard Way book about it.

Another option is to use the editor that comes shipped with Python, sometimes referred to as IDLE. Once you figure out where it is and start it running, go to the file menu and choose new document or something like that. Then press F5 at any time. It should prompt you to save and then run your program. (If I recall correctly.)

I'm sure there's something unclear here, so please respond if you get stuck.

Comment author: Tripitaka 27 May 2012 03:30:08AM -1 points [-]

Thank you very much for your elaborate reply. Unfortunately I do seem to have miscommunicated; those steps as described by you are exactly what I dread. I feel like I do not know enough to ask the right questions, so: I want a program which lets me debug with as less actions as possible while also giving me easily accessible help/documentation. They seem to be called IDEs.

Comment author: lsparrish 27 May 2012 05:47:06AM 3 points [-]

IDLE (which comes with Python) is an IDE. It simplifies testing to the point where you pretty much just hit F5 then hit enter to give it permission to save, and you see the result right away. Alt-tab brings the file you are editing back to the front when you are ready to fix the bug or continue hacking. I've used it on Windows and Linux and the experience is pretty much exactly the same either way. There is also a help menu which takes you to the documentation website where you can search for whatever you are looking for.

Comment author: shokwave 27 May 2012 02:56:29PM 1 point [-]

This may or may not be helpful, but it sounds like you might have a use for guard which is unfortunately quite obtuse to set up, but once it's running, it will automatically perform arbitrary tasks each time the file changes. If I plan to debug something, I tend to go build a Guardfile that runs that something every time I change it. Now the steps are:

  1. Cmd-S to save.
  2. Lazily cast eyes over the other half of my screen to see results.
Comment author: dbaupp 27 May 2012 11:50:10AM 1 point [-]

easily accessible help/documentation

Often, the best (not necessarily easiest, admittedly) way to do this is to have a web browser with tabs open to the documentation for the libraries you are using (doing this method gets easier and much faster with practice, as you can hold more and more of your program in your head).

However, for Python, you could experiment with some of these editors. Just glancing over it, the open source editors Eric and DreamPie and the proprietary Komodo look nice: they appear to offer auto-completion and pop-up documentation, and at least Eric and Komodo have built-in graphical debuggers.

Comment author: Tripitaka 29 May 2012 06:37:54PM -1 points [-]

The perfect solution for my problem got listed here. Thanks again for all of you!