官术网_书友最值得收藏!

Introducing Essential Functional Concepts

Most of the features of functional programming are already first-class parts of Python. Our goal in writing functional Python is to shift our focus away from imperative (procedural or object-oriented) techniques to as much of an extent as possible.

We'll look at each of the following functional programming topics:

  • First-class and higher-order functions, which are sometimes known as pure functions.
  • Immutable data.
  • Strict and non-strict evaluation. We can also call this eager versus lazy evaluation.
  • Recursion instead of an explicit loop state.
  • Functional type systems.

This should reiterate some concepts from the first chapter: firstly, that purely functional programming avoids the complexities of an explicit state maintained through variable assignments; secondly, that Python is not a purely functional language.

This book doesn't attempt to offer a rigorous definition of what functional programming is: Python is not a purely functional language, and a strict definition isn't helpful. Instead, we'll identify some common features that are indisputably important in functional programming. We'll steer clear of the blurry edges, and focus on the obviously functional features.

In this chapter, we'll include some of the Python 3 type hints in the examples. Type hints can help you visualize the essential purpose behind a function definition. Type hints are analyzed with the mypy tool. As with unit testing and static analysis with pylint, mypy can be part of a toolchain used to produce high-quality software.

主站蜘蛛池模板: 高清| 西乌珠穆沁旗| 平南县| 安阳县| 凉山| 阳江市| 山西省| 治多县| 崇义县| 渭源县| 淮北市| 理塘县| 天祝| 邳州市| 西华县| 定西市| 那坡县| 桑日县| 乌鲁木齐市| 和平区| 兴城市| 封丘县| 福州市| 睢宁县| 七台河市| 鹤庆县| 中江县| 云龙县| 宜昌市| 夏邑县| 巢湖市| 淳安县| 奉贤区| 扶风县| 涿鹿县| 中江县| 达拉特旗| 保定市| 盐源县| 冀州市| 郯城县|