Head First Python

Page 39

meet python

Install Python 3 Before you write and run Python code, you need to make sure the Python interpreter is on your computer. In this book, you’ll start out with Release 3 of Python, the very latest (and best) version of the language. A release of Python might already be on your computer. Mac OS X comes with Python 2 preinstalled, as do most versions of Linux (which can also ship with Release 3). Windows, in contrast, doesn’t include any release of Python. Let’s check your computer for Python 3. Open up a command-line prompt and, if you are using Mac OS X or Linux, type:

python3 -V

On Windows, use this command:

That’s an UP “v”, by the wayP.ERCASE

c:\Python31\python.exe -V Using the ” UPPERCASE “vPython he t results in ing on version appear screen. Without the UPPERCASE “v”, you are taken into the Python interpreter. Use the quit() command to exit the interpreter and return to your OS prompt.

Do this!

If Python 3 is missing from your computer, download a copy for your favorite OS from the www.python.org website.

File Edit Window Help WhichPython?

$ python3 -V Python 3.1.2 $ $ python3 Python 3.1.2 (r312:79360M, Mar 24 2010, 01:33:18) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "help", "copyright", "credits" or "license" for more info. >>> >>> quit() $

When you install Python 3, you also get IDLE, Python’s simple—yet surprisingly useful— integrated development environment. IDLE includes a color syntax-highlighting editor, a debugger, the Python Shell, and a complete copy of Python 3’s online documentation set. Let’s take a quick look at IDLE. you are here 4   3


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.