Gabor Guta
Budapest, Hungary
ISBN 978-1-4842-8151-2 e-ISBN 978-1-4842-8152-9
https://doi.org/10.1007/978-1-4842-8152-9
Gabor Guta 2022
Apress Standard
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
This Apress imprint is published by the registered company APress Media, LLC, part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY 10004, U.S.A.
Introduction
Communication gaps can build up in IT workplaces between developers and other roles not requiring programming skills. This gap frequently hurts the projects progress and makes cooperation between participants difficult. My intention is to bridge this gap with this book by explaining the common mental models with which humans think. I will also demonstrate the way these models are applied during the programming process. The book is based on more than two decades of training and software development experience. Python is not only a popular and modern programming language, but it is also an easy-to-learn and efficient tool to reach your goals.
I will not provide too many hands-on exercises and technical details (how an operating system is built, the way a networking protocol works, etc.). Regrettably, I cannot offer a quick option to acquire these skills, as the only way to achieve these skills is with extensive amounts of practice and troubleshooting. This book will give you a strong basis for starting that practice.
Structure and Use of the Book
My intention with the book is to discuss the Python language, along the key concepts, using a new approach. Every chapter of the book starts with the introduction of a particular concept and then goes through the advanced features of the language (as if it were a reference manual).
For those who are just getting acquainted with the language and whose aim is only to understand the major concepts of the programming language, focusing on the first parts of the chapters is recommended. Please feel free to skip the Advanced Features sections. Studying Appendix A will also be worthwhile.
For those who are just becoming acquainted with the language aiming to learn how to program, I recommend running and experimenting with the examples. It will be worthwhile to skim the Advanced Features section and then return to that section later for a detailed reading.
For experienced software developers, it is worthwhile to quickly read the first parts of each chapter by paying attention to the concepts in the Python language that do not exist in other program languages. For such readers, the Advanced Features sections at the end of the chapters are mandatory.
Figures use the UML notation, and a short description of their meaning is shown at the end of Chapters . In the source code examples, I deviate sometimes from the Python coding standard due to the page layout constraints. These appear mostly with short or shortened names and 40- to 50-character lines. Program code examples are conceptually independent units, but they assume former examples of the book have been run, since they may refer to definitions in them. The examples are based on the most up-to-date Python 3.10.2 version available when writing the book. Most of the examples can be run in versions 3.8.x and 3.9.x, which are the most widespread at this time. Results of the examples are intentionally not published in the book. The source code in the book is available for download and you can experiment with it.
Source Code
All source code used in this book is available for you to download from https://github.com/Apress/pragmatic-python-programming .
Installing an Environment
The installation steps for the most widespread operating systems (Windows 10, macOS, Ubuntu Linux 22.04 LTS) are described here so you can run the examples in this book. For another operating system, you can find assistance on the Internet.
Installation on Windows 10
Follow these steps to install and run Python on Windows 10:
Open http://python.org in a browser, select the Downloads menu, and then select Python 3.10.2 (or a newer version if its offered).
The browser automatically launches the download or displays the file download dialog, which starts the download.
After selecting the Download menu, the newly downloaded file appears: python-3.10.2.exe . Launch the installer by clicking the filename.
Select the Add Python 3.10 to PATH option in the installation window and click the Install now button.
The installer continues to inform you about the status of installation. At the end of the installation, select the Disable path length limit option and click the Close button.
Click the magnifying glass icon next to the Windows icon, and start typing in cmd. The icon for the command line appears; open it by pressing Enter.
Install and start a Jupyter lab by entering the python -m pip install jupyterlab and jupyter lab commands (assuming that the working directory will be the user directory).
After launching the Jupyter lab, the contents of the working directory will be displayed. If you download the examples, selecting a file will open it. Or click the New button and select the Python 3 option; an empty notebook will open in a new browser window.
Your Jupyter notebook is built up from cells. The content of the cells can be program code, text, or something else. The default content of the cells is the Python program code you type in. A cell can be run by pressing Shift+Enter. The value of the latest expression will appear under the cell.
Installation on macOS
Follow these steps to install and run Python on macOS:
Open http://python.org in a browser and select the Downloads menu. Then select Python 3.10.2 (or a newer version if its offered).
The browser automatically launches the download or displays the file download dialog, which starts the download.
After selecting the Download menu, the newly downloaded file appears: python-3.10.2-macosx10.9.pkg . Launch the installer by clicking this name.
Confirm the default settings by clicking the Continue buttons in consecutive windows in the browser and then selecting the Install button to launch the installation.