Python Documentation
The official documentation of the Python 3 language is
here. (To be precise that is the Library Reference, which is the part of the documentation you are most likely to delve into.) If you are looking up specifically string functions, odds are that what you want will be in the subsection "Text Sequence Types-str" of the "Built-in Types" section, not in either of the string subsections of the Text Processing Services section.
Installing and configuring Python and an editor on your machine
ONLY do this if you're on your own machine, not on the lab machines!
Installing Python on your machine
While an editor is used for
writing Python programs, all programs must be run (or "executed") by the computer. In order for the computer to be able to understand what your written code means, it needs to be able to understand the Python language.
In this class we will be using Python 3, specifically the Anaconda distribution of Python 3.5.
To install it on your computer:
Go to https://www.continuum.io/downloads
-
Choose whichever of Mac or Windows you have (or Linux if applicable)
-
Click the download button for the Graphical Installer for Python 3.5 version. (The Graphical Installer and the Command-Line installer install exactly the same thing, but the Graphical Installer is much easier to use.)
-
Open the downloaded file, and click Agree/Continue to do the install
- Note: If you see a checkbox in the install dialog asking something like, "Do you want to modify PATH so anaconda is on it" be sure you do check that box. However, the last time we looked, this box is automatically checked and the question isn't even asked in doing a default install.
Installing and configuring VS Code editor on your machine
Go to https://code.visualstudio.com/ and click on the download button in the top right.
- Select the OS X download option for Mac, or the Windows download option for a Windows machine.
- After clicking this, you can find the download in the Downloads folder
Now that you have downloaded the editor, we have to teach the editor how to read and nicely format Python.
Installing the Python plug-in for VS Code
- Open VS Code, and be on the main page with a tool bar of 5 icons on the left.
- Click on the bottom icon, which looks like a square within a square.
- Search Python, and install the plug-in by Don Jayamanne.
- Now, after saving any file in VS Code with .py at the end, you can now write with Python syntax that the editor understands.
Windows only: Install ConEmu terminal
You will need a terminal/shell program; the one built into Mac OS X is nice, but the one that comes with Windows is clunky, so if you are on Windows:
Go to https://conemu.github.io/ and click the download button, and install.
Running Python Files
We discuss this in considerably more detail in the first lab, but the key thing to remember is that you will need a terminal/shell program of some sort.
In brief:
- Open Terminal (Mac); open ConEmu (if you have installed it) or Command Line (Windows)
- Use cd to navigate to your working-on-Python folder, containing your relevant Python projects
- Run any saved file by executing python ./fileName.py
Comments
--
sloan - 2016-08-22
Topic revision: r4 - 2016-09-27 - 03:44:12 - Main.pbeltr1