Figure 1-4: Python entries in Start menu.
Of these, you’ll use:
✓ IDLE (Python GUI)
✓ Python (command line)
To make IDLE and the command line easier to find, pin them to your Start menu:
1. Open your Start menu.
2. Choose All Programs ⇒ Python 2.7.
3. Right-click IDLE (Python GUI). See Figure 1-5.
4. Select Pin to Start Menu.
5. Right-click Python (command line).
6. Select Pin to Start Menu.
You should see the entries at the top of your Start menu. If you prefer, you can pin them to your taskbar.
Figure 1-5: Right-click to pin Python to your Start menu.
Are you interested in running or programming Python using your tablet? If you’re interested in writing a program for a tablet, take a look at the Kivy library. I installed SL4A, the Scripting Layer for Android, on my tablet, along with its Python interpreter and drafted some early chapters using SL4A. Check your tablet’s app store for Python interpreters and see whether any fit your ability.
Because different tablets display graphics different ways, Python has to use special libraries to write programs other than plain text. Tablets are only useful for the non-graphical projects in this book – unless you’re prepared to research those libraries and rewrite the projects to use them. In that case, you’re beyond this book.
Also, it’s better to have a hardware keyboard. Soft (onscreen) keyboards usually don’t give easy access to the punctuation that Python needs (or, in my experience, for everyday English – but that’s another matter … ).
You can’t use this book unless you can start Python. Click Python (command line) that you pinned to your Start menu.
If you haven’t pinned it yet, do it. No, seriously. You can also search for Python in the search bar and click Python (command line) in the Programs section of the results.
You get a window that looks like Figure 1-6.
Figure 1-6: The Python command line suggests you type help if you want help.
Python comes with its own help. In fact, in Figure 1-6 it even tells you about it in the welcome message. If you type help and press Enter, you get more help options. Type help() (including the parentheses) to get interactive help like what you see in Figure 1-7.
Figure 1-7: Python’s interactive help is ready for you to type.
Once you’re inside the help service, you can get information on any topic. Just type the topic. The help service can’t handle complex queries (like the ones you use to search the Internet), so keep it simple. For example, instead of typing how do I get a range of numbers, type range (and read what it has to say). To quit interactive help, type quit.
You can write help text for your own programs. You do it in Project 5.
You can’t use this book unless you can start Python, but you’ll want to stop Python after you’ve started it. If you can’t wait to start programming, skip ahead to Project 2.
You can put the kibosh on Python from the command line by doing one of the following:
✓ Type exit(), including the parentheses. Press Enter. (This works on any platform; Enter = Return if you’re on a Mac.)
✓ Click the close icon for the window that Python’s running in. (This works on any platform.)
✓ On Windows, type Ctrl+Z and then press Enter.
✓ On Linux and Mac, type Ctrl-D.
If you’re on a Mac, make sure you’re using the Ctrl key, not the command key. Also, anytime I mention the Enter key, this means the Return key for you.
As I mention, this book doesn’t cover every single possible potential thing you could do with Python. I just can’t do that in a single book.
Instead, this book exposes you to programming in Python. Sort of like the measles. Use this book as a starting point. If you want more information, you should check out
✓ Python’s online documentation
✓ Python’s introspection features
✓ Professor Internet
✓ Source code (not so much)
Python’s online documentation
The Python documentation pages are available at https://docs.python.org/2.7/. The most helpful sections are listed here:
✓ The Python language reference at https://docs.python.org/2.7/reference/index.html
✓ The Python standard library documentation at https://docs.python.org/2.7/library/index.html
In the left sidebar of the documentation page is a quick search field; you can see it in Figure 1-8. Type your question there and Python will search the documentation for you. It works better if you know the Python keyword, module, or error that you’re interested in.
Figure 1-8: Python’s online documentation can help.
The documentation shows the feature you looked for and a code template for how to use the feature. (See this book’s Introduction for how to read code templates.) These docs have a lot of information, but they assume you know how programmers write documentation. This often makes them hard to understand.
Reading the Python documentation is a skill that you have to master if you want to become a Python master. At the moment, though, don’t worry that it seems like it’s written in a foreign language. Just work through it slowly. As you read more of it, you’ll be able to get more information from it. Soon, docs you couldn’t understand at all will become mind-numbingly boring. Then you’ll know you’re making progress!
Python’s introspection features
The second form of help is Python’s introspection features. Introspection means