liveBook · Manning

Python

As explained in Practices of the Python Pro

Python is a general-purpose, high-level programming language known for readable syntax and a broad software ecosystem.

Python is a readable, high-level language used to move from small utility scripts toward complex, maintainable software. Its syntax resembles written English, lowering the barrier for new programmers while supporting rapid development. section 1.0 section 1.1.2

Python has grown beyond its historical scripting role. It is applied across enterprise software and disciplines including robotics, machine learning, chemistry, and internet services. section 1.1 section 1.1.1

Python supports practical habits for building larger systems:

  • Use the REPL for quick experiments and short feedback cycles. section 1.7.1
  • Move longer-lived or reusable code into modules and functions. section 1.7.1
  • Plan changes and refactor as software grows instead of relying on repeated quick fixes. section 1.7.1
  • Use Python’s tools and dynamic typing without forcing design patterns where they do not fit. section 11.2.1

Sorting state capitals

A REPL experiment starts with a dictionary of states and capitals, extracts the values, encounters an error when calling sort on dict_values, and then uses sorted(capitals). Wrapping the logic in a function or module makes it reusable. section 1.7.1

Listing 1.1. Getting the United States capitals in alphabetical order
>>> us_capitals_by_state = {                                 #1
    'Alabama': 'Montgomery',
    'Alaska': 'Juneau',
    ...
}
>>> capitals = us_capitals_by_state.values()                 #2
dict_values(['Montgomery', 'Juneau'])
>>> capitals.sort()                                          #3
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
AttributeError: 'dict_values' object has no attribute 'sort'
>>> sorted(capitals)                                         #4
['Albany', 'Annapolis', ...]

Inspect the interactive state-capitals example, including the failed sort attempt and the corrected sorted call. section 1.7.1

How Practices of the Python Pro covers it

How deep it goes
Explains readable syntax, enterprise reach, REPL practice, design trade-offs, and dynamic typing, while deferring detailed language features.
Examples
Demonstrates Python through a REPL dictionary transformation, sorted state capitals, functions, modules, and refactored constants.
What it assumes
Assumes foundational Python syntax, data types, and classes, while treating broader software-design ideas as transferable across languages.
What you can do after
Evaluate/understand Python as a language for prototyping, interactive experiments, maintainable systems, and enterprise software.
How it connects
Connects Python with software design, design patterns, the REPL, dynamic typing, rapid prototyping, and refactoring.

Also explained in

Compare how 26 books explain Python →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Practices of the Python Pro. The section links point to the parts of the book it draws on.