python_how-to_preface

Python How-To - Preface

Return to Python How-To Table of Contents, Python How-To, Python, Python Bibliography, Manning Python Series, Manning Data Science Series, Manning Books Purchased by Cloud Monk, Manning Bibliography, Cloud Monk's Book Purchases, Cloud Monk Library

“ (PyHow2 2023)

preface

” (PyHow2 2023)

“We're probably the luckiest generation in human history. We're no longer in the Neolithic Age or the Industrial Age; we've entered the Information Age. Advanced information technologies, particularly computers and networks, have transformed human life. We can take a flight from our hometown to another place thousands of miles away in less than half a day. We can make a doctor's appointment using a smartphone and attend the appointment through a video call, if we prefer. We can order almost anything from online stores and get it delivered within days or even hours.” (PyHow2 2023)

These transformations have been accompanied by the accumulation of tremendous amounts of data over the past couple of decades. The work of processing and analyzing this data has contributed to the emergence of a new interdisciplinary subject: data science. As a behavioral scientist, I spend a significant amount of time dealing with data, so you might say that I'm applying data science to behavioral research. It takes more than paper and pencil to process data of this magnitude, however. Instead, I've been writing code to clean data and run statistical models with a wonderful programming language: Python.

As a self-taught coder, I know it's not easy to grasp Python or any other programming language — not because it takes a long time to learn all the techniques (and know which ones to use when), but because too many learning resources are available, such as online courses, tutorial videos, blog articles, and certainly books. How do you choose the ones that are most suitable for you?

I had the same question when I started learning Python. Over the years, I've tried a variety of resources, and I've found that the best learning resources are books, because books have well-structured content that makes it possible to take a deep dive into the language. During the learning process, you can set your own pace. Whenever you need to, you can slow down to digest hard topics. In addition, you can refer to the books on your bookshelf quickly should any questions arise.

Most of the Python books on the market are written for beginners (providing detailed coverage of the language's basic features) or advanced users (covering specialized techniques that are less generalizable). Without doubt, a few of those books are great. From the learning-curve perspective, however, I felt that a book was missing: one for Python learners at the late-beginner and early-intermediate levels. These stages are critical, as learners are forming the right coding habits and figuring out the proper Pythonic techniques for a given context. From the content perspective, I thought the missing book should address general programming problems that most readers could relate to their work, no matter what they do with Python: web development or data science. In other words, more readers could benefit from such a book because it would provide general domain-independent knowledge.

I wrote this book to fill the gap between beginner and advanced books. I hope you'll feel that you've learned a few things after reading it.

acknowledgments

I'd like to thank my mentors, Dr. Paul Cinciripini and Dr. Jason Robinson at the University of Texas MD Anderson Cancer Center, for supporting me as I pursued the use of Python as the language for our analytic work. That effort eventually led to this book.

I also want to thank the Manning team: Publisher Marjan Bace for leading the excellent editorial and production teams; Associate Publisher Michael Stephens for inviting me to write this book; Senior Development Editor Marina Michaels for coordinating and editing; René van den Berg for technical editing; Walter Alexander and Ignacio Torres for providing code review; Aleksandar Dragosavljević for organizing peer reviews; as well as the production staff for their hard work in formatting this book.

Finally, thank you to the reviewers, who provided valuable feedback: Alexei Znamensky, Alexey Vyskubov, Ariel Andres, Brent Boylan, Chris Kolosiwsky, Christopher Kardell, Christopher Villanueva, Claudiu Schiller, Clifford Thurber, Dirk Gomez, Ganesh Swaminathan, Georgios Doumas, Gerald Mack, Gregory Grimes, Igor Dudchenko, Iyabo Sindiku, James Matlock, Jeffrey M. Smith, Josh McAdams, Keerthi Shetty, Larry Cai, Louis Aloia, Marcus Geselle, Mary Anne Thygesen, Mike Baran, Ninoslav Cerkez, Oliver Korten, Piergiorgio Faraglia, Radhakrishna M.V., Rajinder Yadav, Raymond Cheung, Robert Wenner, Shankar Swamy, Sriram Macharla, Giri S. Swaminathan, Steven Herrera, and Vitosh K. Doynov. Their suggestions helped make this a better book.

About this book

In this book, I focus on teaching the essential techniques of Python from a specialty-independent perspective. Although a variety of Python packages are available for different specialties, such as data science and web development, these packages are built on the core features of Python. No matter what domain-specific Python packages you use for your job, you must have a good understanding of essential techniques, such as choosing the proper data models and writing well-structured functions and classes. These techniques make it possible for you to use your domain-specific packages comfortably.

Who should read this book

If you've been self-teaching and using Python for some time, but feel that your Python knowledge is unstructured, I consider you to be a late-beginner or early-intermediate user. This book is right for you because you need to reinforce and synthesize your Python knowledge in a structured way. In this book, I identify several topics in each chapter to address common problems that you may encounter in your work. My coverage of these topics teaches you more than how to address a specific problem; it also frames the content in a larger context, showing why and how the topic matters when you're working on a project. This way, you're not learning individual techniques to complete separate tasks; you're completing a project and learning these techniques in the process.

How this book is organized: A road map

This book consists of six parts, as shown in the following figure. In the first part (chapters 2-5), you study the built-in data models, such as strings, lists, and dictionaries. These data models are the building blocks of any project. In the second part (chapters 6 and 7), you learn about best practices for defining functions. Functions are integral to any project because they're responsible for manipulating data to create the desired output. In the third part (chapters 8 and 9), you learn techniques for defining custom classes. Instead of using built-in classes, we define custom classes to better model the data in our project. In the fourth part (chapters 10 and 11), you learn the fundamentals of using objects and manipulating files on your computers. In the fifth part (chapters 12 and 13), you learn a variety of techniques to safeguard your programs, including logging, exception handling, and testing. In the sixth part (chapter 14), you synthesize all the knowledge you've gained to produce a web app — a project that serves as the teaching frame in all the other chapters.

To follow along with the teaching, I recommend that you use a computer while you're studying this book, which will allow you to get familiar with Python syntax and techniques faster. I've uploaded all the code in GitHub, and you can find my public repository at https://github.com/ycui1/python_how_to. In this book, however, whenever I show you some code, I provide the necessary explanations and output, so it's fine if you don't have a computer around while you're reading this book.

If you do intend to use a computer, your computer's operating system doesn't matter. Windows, macOS, and Linux are all fine because Python is a cross-platform programming language. (See appendix A online for Python installation instructions.) Because I focus on the essential techniques, which have stabilized in recent Python releases, it's not too important whether your computer runs Python 3.8 or earlier, but to get the most out of the book, I recommend that you install Python 3.10 or later.

About the appendices

The online version of this book has five appendices. Appendix A, Learning Python with REPL in IDLE, shows how to write Python code interactively. Appendix B, Managing Python packages with pip, shows how to manage Python packages. Appendix C, Using Jupyter Notebook: A web-based interactive Python editor, shows how to work with Jupyter Notebook. Appendix D, Integrating version control into your project, shows the importance of version control in your codebase. Appendix E, Preparing your package for public distribution, shows how to publish your package.

About the code

This book contains many examples of source code, both in numbered listings and inline with normal text. In both cases, source code is formatted in a fixed-width font like this to separate it from ordinary text. Sometimes, code is also in bold to highlight changes from previous steps in the chapter, such as when a new feature adds to an existing line of code.

In many cases, the original source code has been reformatted; I've added line breaks and reworked indentation to accommodate the available page space in the book. In rare cases, listings include line-continuation markers (➥). Additionally, comments in the source code have been removed from the listings when the code is described in the text. Code annotations accompany many of the listings, highlighting important concepts.

You can get executable snippets of code from the liveBook (online) version of this book at https://livebook.manning.com/book/python-how-to. The complete code for the examples in the book is available for download from the Manning website at https://www.manning.com/books/python-how-to and from GitHub at https://github.com/ycui1/python_how_to.

liveBook discussion forum

Purchase of Python How-To includes free access to liveBook, Manning's online reading platform. Using liveBook's exclusive discussion features, you can attach comments to the book globally or to specific sections or paragraphs. It's a snap to make notes for yourself, ask and answer technical questions, and receive help from the author and other users. To access the forum, go to https://livebook.manning.com/book/python-how-to/discussion. You can learn more about Manning's forums and the rules of conduct at https://livebook.manning.com/discussion.

Manning's commitment to our readers is to provide a venue where meaningful dialogue between individual readers and between readers and the author can take place. It is not a commitment to any specific amount of participation on the part of the author, whose contribution to the forum remains voluntary (and unpaid). We suggest that you try asking the author some challenging questions, lest their interest stray! The forum and the archives of previous discussions will be accessible on the publisher's website as long as the book is in print.

Other online resources

You can find official documentation, including tutorials and references, at https://docs.python.org/3. The author, Dr. Yong Cui, regularly writes blogs on Python and related data science topics at Medium (https://medium.com/@yongcui01).

About the author

Dr. Yong Cui is a scientist who has been working in the biomedicine field for more than 15 years. His research focuses on developing mobile health apps for behavioral interventions using Swift and Kotlin. As his favorite language, Python is his go-to language for data analysis, machine learning, and research-tool development. In his spare time, he likes to write blog posts on a variety of technical topics, including mobile development, Python programming, and artificial intelligence.

about the cover illustration

The figure on the cover of Python How-To is titled “Paysanne des environs de Soleure,” or “Peasant woman around Solothurn,” taken from a collection by Jacques Grasset de Saint-Sauveur, published in 1788. Each illustration is finely drawn and hand-colored.

In those days, it was easy to identify where people lived and what their trade or station in life was by their dress alone. Manning celebrates the inventiveness and initiative of the computer business with book covers based on the rich diversity of regional culture centuries ago, brought back to life by pictures from collections such as this one.

“ (PyHow2 2023)

Fair Use Sources

Python: Python Variables, Python Data Types, Python Control Structures, Python Loops, Python Functions, Python Modules, Python Packages, Python File Handling, Python Errors and Exceptions, Python Classes and Objects, Python Inheritance, Python Polymorphism, Python Encapsulation, Python Abstraction, Python Lists, Python Dictionaries, Python Tuples, Python Sets, Python String Manipulation, Python Regular Expressions, Python Comprehensions, Python Lambda Functions, Python Map, Filter, and Reduce, Python Decorators, Python Generators, Python Context Managers, Python Concurrency with Threads, Python Asynchronous Programming, Python Multiprocessing, Python Networking, Python Database Interaction, Python Debugging, Python Testing and Unit Testing, Python Virtual Environments, Python Package Management, Python Data Analysis, Python Data Visualization, Python Web Scraping, Python Web Development with Flask/Django, Python API Interaction, Python GUI Programming, Python Game Development, Python Security and Cryptography, Python Blockchain Programming, Python Machine Learning, Python Deep Learning, Python Natural Language Processing, Python Computer Vision, Python Robotics, Python Scientific Computing, Python Data Engineering, Python Cloud Computing, Python DevOps Tools, Python Performance Optimization, Python Design Patterns, Python Type Hints, Python Version Control with Git, Python Documentation, Python Internationalization and Localization, Python Accessibility, Python Configurations and Environments, Python Continuous Integration/Continuous Deployment, Python Algorithm Design, Python Problem Solving, Python Code Readability, Python Software Architecture, Python Refactoring, Python Integration with Other Languages, Python Microservices Architecture, Python Serverless Computing, Python Big Data Analysis, Python Internet of Things (IoT), Python Geospatial Analysis, Python Quantum Computing, Python Bioinformatics, Python Ethical Hacking, Python Artificial Intelligence, Python Augmented Reality and Virtual Reality, Python Blockchain Applications, Python Chatbots, Python Voice Assistants, Python Edge Computing, Python Graph Algorithms, Python Social Network Analysis, Python Time Series Analysis, Python Image Processing, Python Audio Processing, Python Video Processing, Python 3D Programming, Python Parallel Computing, Python Event-Driven Programming, Python Reactive Programming.

Variables, Data Types, Control Structures, Loops, Functions, Modules, Packages, File Handling, Errors and Exceptions, Classes and Objects, Inheritance, Polymorphism, Encapsulation, Abstraction, Lists, Dictionaries, Tuples, Sets, String Manipulation, Regular Expressions, Comprehensions, Lambda Functions, Map, Filter, and Reduce, Decorators, Generators, Context Managers, Concurrency with Threads, Asynchronous Programming, Multiprocessing, Networking, Database Interaction, Debugging, Testing and Unit Testing, Virtual Environments, Package Management, Data Analysis, Data Visualization, Web Scraping, Web Development with Flask/Django, API Interaction, GUI Programming, Game Development, Security and Cryptography, Blockchain Programming, Machine Learning, Deep Learning, Natural Language Processing, Computer Vision, Robotics, Scientific Computing, Data Engineering, Cloud Computing, DevOps Tools, Performance Optimization, Design Patterns, Type Hints, Version Control with Git, Documentation, Internationalization and Localization, Accessibility, Configurations and Environments, Continuous Integration/Continuous Deployment, Algorithm Design, Problem Solving, Code Readability, Software Architecture, Refactoring, Integration with Other Languages, Microservices Architecture, Serverless Computing, Big Data Analysis, Internet of Things (IoT), Geospatial Analysis, Quantum Computing, Bioinformatics, Ethical Hacking, Artificial Intelligence, Augmented Reality and Virtual Reality, Blockchain Applications, Chatbots, Voice Assistants, Edge Computing, Graph Algorithms, Social Network Analysis, Time Series Analysis, Image Processing, Audio Processing, Video Processing, 3D Programming, Parallel Computing, Event-Driven Programming, Reactive Programming.


Python Glossary, Python Fundamentals, Python Inventor: Python Language Designer: Guido van Rossum on 20 February 1991; PEPs, Python Scripting, Python Keywords, Python Built-In Data Types, Python Data Structures - Python Algorithms, Python Syntax, Python OOP - Python Design Patterns, Python Module Index, pymotw.com, Python Package Manager (pip-PyPI), Python Virtualization (Conda, Miniconda, Virtualenv, Pipenv, Poetry), Python Interpreter, CPython, Python REPL, Python IDEs (PyCharm, Jupyter Notebook), Python Development Tools, Python Linter, Pythonista-Python User, Python Uses, List of Python Software, Python Popularity, Python Compiler, Python Transpiler, Python DevOps - Python SRE, Python Data Science - Python DataOps, Python Machine Learning, Python Deep Learning, Functional Python, Python Concurrency - Python GIL - Python Async (Asyncio), Python Standard Library, Python Testing (Pytest), Python Libraries (Flask), Python Frameworks (Django), Python History, Python Bibliography, Manning Python Series, Python Official Glossary - Python Glossary, Python Topics, Python Courses, Python Research, Python GitHub, Written in Python, Python Awesome List, Python Versions. (navbar_python - see also navbar_python_libaries, navbar_python_standard_library, navbar_python_virtual_environments, navbar_numpy, navbar_datascience)


© 1994 - 2024 Cloud Monk Losang Jinpa or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.


python_how-to_preface.txt · Last modified: 2024/04/28 03:52 by 127.0.0.1