Concepts / Installing Python on Your Computer

Installing Python on Your Computer

Notepad and other basic text editors are unsuitable for Python because they lack syntax highlighting and do not support automatic indentation properly.

  • Programming

Why the Editor Matters

Python programs are written as text, but that does not mean every text editor is suitable for writing them. A basic editor such as Notepad on Windows or TextEdit on Mac may already be installed, yet these tools lack the programming features that make Python code readable and structurally correct. The two essential features to look for are syntax highlighting and automatic indentation.

CapabilityNotepad or similar basic editorPython-capable editor
Syntax highlightingNot providedColors different code elements
Automatic indentationDoes not support it properlyMoves the cursor to the appropriate indentation level
Help with Python structureProvides no specialized feedbackMakes code structure easier to see and indentation easier to maintain

The practical difference between a basic text editor and an editor designed for programming

Notepadbasic text editingPlain codeno syntax highlightingColored tokenssyntax highlightingManual spacingno automatic indentationPython editorprogramming featuresIndented cursorautomatic indentationoffersoffersoffersoffers
What can a Python editor do that a basic editor cannot?

Indentation Defines Structure

Python uses indentation as part of its syntax. Indentation defines code blocks, control flow, and function bodies. An if block, loop body, or function body must be indented. In this respect, indentation is not optional decoration: an indentation mistake is a syntax error that prevents the program from running.

Before
if score > 90:
print("winning")

The statement is not indented as part of the if block.

After
if score > 90:
    print("winning")

The statement is indented as part of the if block.

if score > 90:if score > 90:print("winning")print("winning")indentedintended blockcontains
What changes when a statement is correctly versus incorrectly indented under an if statement?

Syntax Highlighting in Action

Syntax highlighting colors different parts of code according to their roles. A Python editor recognizes keywords such as if, for, and def, along with string literals, variable names, numbers, and comments beginning with a hash symbol. The editor applies different colors or text styles while you type.

ifkeywordscorevariable name>comparison operator90number:block marker# winningcomment
How does syntax highlighting visually distinguish the different elements in a Python statement?
Worked example

Spotting a Missing Quote

Use syntax highlighting to notice a possible error in a string.

  1. 1
    Type a string

    A Python editor normally displays a string literal in its string color.

  2. 2
    Omit the closing quotation mark

    The editor may display the rest of the file in string color because it interprets later text as part of the unfinished string.

  3. 3
    Investigate the color change

    The unusual coloring gives you a visual signal to check the quotation mark.

Result

Syntax highlighting can expose a missing closing quotation mark before you run the program.

Automatic Indentation

When you press Enter after a line that begins a new code block, a Python editor automatically moves the cursor to the appropriate indentation level. For example, after typing if x > 5: and pressing Enter, a programming editor places the cursor inside the block. The source material describes this level as typically four spaces in Python convention. In Notepad, the cursor moves to the beginning of the next line, so you must add the spaces yourself.

if x > 5:block beginsPress Enternew lineIndented cursortypically 4 spacesBlock statementready to typefinish lineeditor indentstype inside block
How does an editor move the cursor and preserve the correct indentation after an if statement?
Before
if x > 5:
[beginning of next line]

A basic editor leaves the cursor at the beginning of the new line.

After
if x > 5:
    [cursor]

A Python editor places the cursor at the block's indentation level.

Choosing Your Editor

The appropriate editor depends on your experience level and what you want to accomplish. The recommended starting point for beginners is Light Table. It is free, available on all major operating systems, and provides the essential features without unnecessary complexity.

Vim and Emacs are powerful alternatives for experienced programmers, but they require significant time to learn. For a first Python editor, prioritize programming support rather than choosing the general-purpose editor that happens to be pre-installed on your computer.

Beginnerneeds a simple startingpointLight Tablefree; major operatingsystemsExperiencedprogrammercan invest time to learnVimpowerful; significantlearning timeEmacspowerful; significantlearning timesuitable choicepossible choicepossible choice
How do experience level and operating-system availability guide the choice of a Python editor?
SituationSuitable directionReason
New to programmingLight TableIt is free, available on all major operating systems, and beginner-friendly.
Experienced programmerVim or EmacsThese are powerful alternatives, but they require significant time to learn.
Considering Notepad or another basic editorChoose a programming editor insteadBasic editors lack syntax highlighting and proper automatic indentation.

Editor choices described in the source material

Mistakes Beginners Make

  • Common mistake

    Using the editor that came pre-installed on the computer

    What it looks like

    Choosing Notepad on Windows or TextEdit on Mac simply because it is already available

    Why it fails

    These basic editors do not provide syntax highlighting or proper automatic indentation.

    Do this instead

    Choose an editor designed for programming and confirm that it provides both essential Python features.

  • Common mistake

    Treating indentation as optional formatting

    What it looks like

    Typing a statement under if without indenting it

    Why it fails

    Python uses indentation to define code blocks, so an indentation mistake is a syntax error that prevents the program from running.

    Do this instead

    Use an editor that automatically indents after a statement that begins a block.

  • Common mistake

    Ignoring unexpected syntax colors

    What it looks like

    Continuing to type after forgetting a closing quotation mark

    Why it fails

    The editor may color the rest of the file as a string, providing a visual warning that the string is unfinished.

    Do this instead

    Treat an unexpected change in syntax highlighting as a reason to check the nearby code.

  • Common mistake

    Selecting a powerful editor without considering learning time

    What it looks like

    Choosing Vim or Emacs as a beginner without allowing time to learn the editor

    Why it fails

    The source material identifies these as powerful alternatives that require significant time to learn.

    Do this instead

    Start with a beginner-friendly option such as Light Table unless you already have the experience and time needed for Vim or Emacs.

Check Your Understanding

EASY

A learner types if x > 5: in a basic editor and presses Enter. The cursor appears at the beginning of the next line. What two actions must the learner take, and what feature would make the second action easier?

Hints
  • Think about what Python requires after a line that begins a code block.
  • Compare manual spacing with the behavior of automatic indentation.
Worked example

Applying the Two-Feature Test

Evaluate whether an editor is suitable for beginning Python programming.

  1. 1
    Check syntax highlighting

    Ask whether the editor distinguishes keywords, strings, variable names, numbers, and comments through color or text style.

  2. 2
    Check automatic indentation

    Ask whether pressing Enter after a statement that begins a block moves the cursor to the appropriate indentation level.

  3. 3
    Compare the result with your experience

    For a beginner, Light Table is the recommended option in the source material. Vim and Emacs are alternatives for experienced programmers who can invest significant learning time.

Result

An editor that lacks either syntax highlighting or proper automatic indentation is not a suitable choice for learning Python.

Key Takeaways

  1. 1
    Notepad, TextEdit, and similar basic editors are unsuitable for Python because they lack syntax highlighting and proper automatic indentation.
  2. 2
    Syntax highlighting separates keywords, strings, variables, numbers, and comments visually and can reveal mistakes such as a missing closing quotation mark.
  3. 3
    Indentation defines Python code structure, including if blocks, loops, and function bodies.
  4. 4
    Automatic indentation reduces manual spacing and helps prevent indentation errors.
  5. 5
    Light Table is recommended for beginners, while Vim and Emacs are powerful alternatives for experienced programmers who are prepared to learn them.

At a glance

  • A Python editor must provide syntax highlighting and automatic indentation.
  • Python indentation is part of the language syntax and defines code structure.
  • Syntax highlighting improves readability and can expose errors visually.
  • Automatic indentation helps maintain the correct structure after statements such as if, for, and def.
  • Light Table is the recommended beginner editor in the source material; Vim and Emacs suit experienced programmers willing to learn them.

More concepts starting with I