وبلاگ بلیان

Learn Python Programming: A comprehensive, up-to-date, and definitive guide to learning Python 4th Edition

معرفی کتاب «Learn Python Programming: A comprehensive, up-to-date, and definitive guide to learning Python 4th Edition» نوشتهٔ FABRIZIO. KRUGER ROMANO (HEINRICH.)، منتشرشده توسط نشر Packt در سال 2024. این کتاب در فرمت epub، زبان انگلیسی ارائه شده است. «Learn Python Programming: A comprehensive, up-to-date, and definitive guide to learning Python 4th Edition» در دستهٔ بدون دسته‌بندی قرار دارد.

This edition offers updated content covering Python 3.9 to 3.12, new chapters on type hinting and CLI applications, and expanded practical examples, making it the ideal resource for both new and experienced Python programmers Key Features Create and deploy APIs and CLI applications, leveraging Python’s strengths in scripting and automation Stay current with the latest features and improvements in Python, including pattern matching and the latest exception handling syntax Engage with new real-world examples and projects, including competitive programming problems, to solidify your understanding of Python Book Description Learn Python Programming, Fourth Edition, provides a comprehensive, up-to-date introduction to Python programming, covering fundamental concepts and practical applications. This edition has been meticulously updated to include the latest features from Python versions 3.9 to 3.12, new chapters on type hinting and CLI applications, and updated examples reflecting modern Python web development practices. This Python book empowers you to take ownership of writing your software and become independent in fetching the resources you need. By the end of this book, you will have a clear idea of where to go and how to build on what you have learned from the book. Through examples, the book explores a wide range of applications and concludes by building real-world Python projects based on the concepts you have learned. This Python book offers a clear and practical guide to mastering Python and applying it effectively in various domains, such as data science, web development, and automation. What you will learn Install and set up Python on Windows, Mac, and Linux Write elegant, reusable, and efficient code Avoid common pitfalls such as duplication and over-engineering Use functional and object-oriented programming approaches appropriately Build APIs with FastAPI and program CLI applications Understand data persistence and cryptography for secure applications Manipulate data efficiently using Python's built-in data structures Package your applications for distribution via the Python Package Index (PyPI) Solve competitive programming problems with Python Who this book is for This Python programming book is for everyone who wants to learn Python from scratch, as well as experienced programmers looking for a reference book. Prior knowledge of basic programming concepts will help you follow along, but it’s not a prerequisite Preface Who this book is for What this book covers To get the most out of this book Get in touch A Gentle Introduction to Python A brief introduction to programming Enter the Python About Python Portability Coherence Developer productivity An extensive library Software quality Software integration Data science Satisfaction and enjoyment What are the drawbacks? Who is using Python today? Setting up the environment Installing Python Useful installation resources Installing Python on Windows Installing Python on macOS Installing Python on Linux The Python console About virtual environments Your first virtual environment Installing third-party libraries The console How to run a Python program Running Python scripts Running the Python interactive shell Running Python as a service Running Python as a GUI application How is Python code organized? How do we use modules and packages? Python’s execution model Names and namespaces Scopes Guidelines for writing good code Python culture A note on IDEs A word about AI Summary Built-In Data Types Everything is an object Mutability Numbers Integers Booleans Real numbers Complex numbers Fractions and decimals Immutable sequences Strings and bytes Encoding and decoding strings Indexing and slicing strings String formatting Tuples Mutable sequences Lists Bytearrays Set types Mapping types: dictionaries Data types Dates and times The standard library Third-party libraries The collections module namedtuple defaultdict ChainMap Enums Final considerations Small value caching How to choose data structures About indexing and slicing About names Summary Conditionals and Iteration Conditional programming The if statement A specialized else: elif Nesting if statements The ternary operator Pattern matching Looping The for loop Iterating over a range Iterating over a sequence Iterators and iterables Iterating over multiple sequences The while loop The break and continue statements A special else clause Assignment expressions Statements and expressions Using the walrus operator A word of warning Putting all this together A prime generator Applying discounts A quick peek at the itertools module Infinite iterators Iterators terminating on the shortest input sequence Combinatoric generators Summary Functions, the Building Blocks of Code Why use functions? Reducing code duplication Splitting a complex task Hiding implementation details Improving readability Improving traceability Scopes and name resolution The global and nonlocal statements Input parameters Argument-passing Assignment to parameter names Changing a mutable object Passing arguments Positional arguments Keyword arguments Iterable unpacking Dictionary unpacking Combining argument types Defining parameters Optional parameters Variable positional parameters Variable keyword parameters Positional-only parameters Keyword-only parameters Combining input parameters More signature examples Avoid the trap! Mutable defaults Return values Returning multiple values A few useful tips Recursive functions Anonymous functions Function attributes Built-in functions Documenting your code Importing objects Relative imports One final example Summary Comprehensions and Generators The map, zip, and filter functions map zip filter Comprehensions Nested comprehensions Filtering a comprehension Dictionary comprehensions Set comprehensions Generators Generator functions Going beyond next The yield from expression Generator expressions Some performance considerations Do not overdo comprehensions and generators Name localization Generation behavior in built-ins One last example Summary OOP, Decorators, and Iterators Decorators A decorator factory OOP The simplest Python class Class and object namespaces Attribute shadowing The self argument Initializing an instance OOP is about code reuse Inheritance and composition Accessing a base class Multiple inheritance Method resolution order Class and static methods Static methods Class methods Private methods and name mangling The property decorator The cached_property decorator Operator overloading Polymorphism—a brief overview Data classes Writing a custom iterator Summary Exceptions and Context Managers Exceptions Raising exceptions Defining your own exceptions Tracebacks Handling exceptions Exception groups Not only for errors Context managers Class-based context managers Generator-based context managers Summary Files and Data Persistence Working with files and directories Opening files Using a context manager to open a file Reading from and writing to a file Reading and writing in binary mode Protecting against overwriting an existing file Checking for file and directory existence Manipulating files and directories Manipulating pathnames Temporary files and directories Directory content File and directory compression Data interchange formats Working with JSON Custom encoding/decoding with JSON I/O, streams, and requests Using an in-memory stream Making HTTP requests Persisting data on disk Serializing data with pickle Saving data with shelve Saving data to a database Configuration files Common formats The INI configuration format The TOML configuration format Summary Cryptography and Tokens The need for cryptography Useful guidelines Hashlib HMAC Secrets Random objects Token generation Digest comparison JSON Web Tokens Registered claims Time-related claims Authentication-related claims Using asymmetric (public key) algorithms Useful references Summary Testing Testing your application The anatomy of a test Testing guidelines Unit testing Writing a unit test Mock objects and patching Assertions Testing a CSV generator Boundaries and granularity Testing the export function Final considerations Test-driven development Summary Debugging and Profiling Debugging techniques Debugging with print Debugging with a custom function Using the Python debugger Inspecting logs Other techniques Reading tracebacks Assertions Where to find information Troubleshooting guidelines Where to inspect Using tests to debug Monitoring Profiling Python When to profile Measuring execution time Summary Introduction to Type Hinting Python approach to types Duck typing History of type hinting Benefits of type hinting Type annotations Annotating functions The Any type Type aliases Special forms Optional Union Generics Annotating variables Annotating containers Annotating tuples Fixed-length tuples Tuples with named fields Tuples of arbitrary length Abstract base classes (ABCs) Special typing primitives The Self type Annotating variable parameters Protocols The Mypy static type checker Some useful resources Summary Data Science in Brief IPython and Jupyter Notebook Using Anaconda Starting a Notebook Dealing with data Setting up the Notebook Preparing the data Cleaning the data Creating the DataFrame Unpacking the campaign name Unpacking the user data Renaming columns Computing some metrics Cleaning everything up Saving the DataFrame to a file Visualizing the results Where do we go from here? Summary Introduction to API Development The Hypertext Transfer Protocol How does HTTP work? Response status codes APIs – An introduction What is an API? What is the purpose of an API? API protocols API data-exchange formats The railway API Modeling the database Main setup and configuration Application settings Station endpoints Reading data Creating data Updating data Deleting data User authentication Documenting the API Where do we go from here? Summary CLI Applications Command-line arguments Positional arguments Options Sub-commands Argument parsing Building a CLI client for the railway API Interacting with the railway API Creating the command-line interface Configuration files and secrets Creating sub-commands Implementing sub-commands Other resources and tools Summary Packaging Python Applications The Python Package Index Packaging with Setuptools Project layout Development installation Changelog License README pyproject.toml Package metadata Versioning and dynamic metadata Specifying dependencies Project URLs Scripts and entry points Defining the package contents Accessing metadata in your code Building and publishing packages Building Publishing Advice for starting new projects Other files Alternative tools Further reading Summary Programming Challenges Advent of Code Camel Cards Part one – problem statement Part one – solution Part two – problem statement Part two – solution Cosmic Expansion Part one – problem statement Part one – solution Part two – problem statement Part two – solution Final considerations Other programming challenge websites Summary Index
دانلود کتاب Learn Python Programming: A comprehensive, up-to-date, and definitive guide to learning Python 4th Edition