First I downloaded Python. I used the 2x version first because that was recommended by the udacity cite where this all started. For reasons explained latter, I also downloaded the 3x version. There seems to be no problem with running these both on the same machine. The 3x version was the one I downloaded last and it is the version that starts automatically.
Downloading Python from the Python.org site was simple. The installer worked fine. However, in keeping with the MSWin paradigm, I did choose to install it in C:\Program Files\. This turned out alright in the end but required remembering this when using some of the documentation.
Getting the Python Interpreter to run is very straight forward after the install is complete. Click Start >> Run and type "python" in the run window. The Python interpreter will start up in a new window. However, the interpreter just runs each line as you enter it so it does not work well for anything except the most trivial experimentation or for use as a calculator.
Handily, the install also makes .py a new known extension so you can use notepad (or preferably notepad2) to create a file, save it with the .py extension and then execute it by double clicking the file. However, doing this opens Python in a window, Python executes the file as a script and then closes the window when the script is complete. Not so useful if you want to review the results.
I am familiar with working in an integrated development environment(ide) like MSVisualStudio so started looking for something similar for the Python environment. As I looked for options it appeared that I would need the 3x version as the ide of my choice (Ninja-ide) required other open source tools that had been upgraded to 3x.
BTW, I ended up being very frustrated trying to get Ninja-ide working and am not currently doing so.
Eventually, I discovered IDLE. IDLE is a program mentioned several times in the documentation. IDLE is an ide written in Python. It is included in the MSWin version of the Python download although the documentation about how to run and use it is confusing. It is not a .exe file and is not an installed program in the windows program directory. It is a .pyw file in the Python3x\Lib\idlelib\ directory and there is a .bat file in this directory which will run IDLE.
So in the end, here is what I did. I wanted to keep all my own .py files in a single directory (for now) which I have labelled Python_Projects. I created a shortcut from the idle.bat file on my desktop, renamed the desktop version to "IDLE from Python_Projects", then changed the Start in: property of the "IDLE from Python_Projects" shortcut to the full path to Python_Projects.
Now I click on the IDLE icon on my desktop and it starts IDLE with Python_Projects as the default path. This has the happy result of including Python_Projects in the sys.path used by Python to look for scripts and modules. And Python_Projects now becomes the default path from which IDLE opens and saves files.
This situation works much better than using either of the other options. IDLE is a little awkward at first because it opens a separate window for editing and the python interpreter, but it does allow for editing a file, pressing F5 which will save the file, then run it in the interpreter window and you can see the results. It also has some limited debug facilities but for now works fine.
At this point I am just reading documentation and want to copy code snippets and test them as I go
and IDLE allows me to do that just fine.
Obviously, more to come.
No comments:
Post a Comment