# xianhu/learnpython

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/xianhu-learnpython).**

8,484 stars · 4,061 forks · Jupyter Notebook

## Links

- GitHub: https://github.com/xianhu/LearnPython
- Homepage: https://github.com/xianhu/LearnPython
- awesome-repositories: https://awesome-repositories.com/repository/xianhu-learnpython.md

## Topics

`learning-python` `python` `python-flask` `python-requests`

## Description

LearnPython is a programming tutorial consisting of a collection of practical code examples used to demonstrate Python language features and programming patterns. It serves as a comprehensive learning resource that implements core language concepts through functional code.

The project provides specialized guides and samples covering several key domains. These include asynchronous network programming with event loops and coroutines, data visualization using numerical datasets for 2D and 3D plots, and web scraping for fetching content and automating login flows. It also features instructions on relational database management through object-relational mapping and the construction of TCP socket servers and clients.

Broadly, the repository covers capabilities in numerical computing with multidimensional arrays, natural language processing, and the implementation of concurrency patterns such as producer-consumer queues. It also includes examples of web framework components, including URL routing and request lifecycle management.

The project is delivered as a series of Jupyter Notebooks.

## Tags

### Education & Learning Resources

- [Programming Language Concepts](https://awesome-repositories.com/f/education-learning-resources/programming-language-concepts.md) — Demonstrates Python language features and programming patterns through a comprehensive collection of practical code examples. ([source](https://github.com/xianhu/LearnPython/blob/master/README.md))
- [Python Learning Resources](https://awesome-repositories.com/f/education-learning-resources/python-learning-resources.md) — Serves as a comprehensive educational resource for learning the Python programming language through practical examples.
- [Python Programming Tutorials](https://awesome-repositories.com/f/education-learning-resources/python-programming-tutorials.md) — Provides instructional content and practical code examples to demonstrate Python language features and patterns.
- [Web Scraping Courses](https://awesome-repositories.com/f/education-learning-resources/python-programming-guides/web-scraping-courses.md) — Includes practical educational materials on fetching web content, managing HTTP headers, and automating login flows.
- [TCP/IP Socket Programming Guides](https://awesome-repositories.com/f/education-learning-resources/tcp-ip-socket-programming-guides.md) — Offers educational guides on implementing TCP socket servers, clients, and SMTP email communication.

### Data & Databases

- [Raw SQL Execution](https://awesome-repositories.com/f/data-databases/data-access-querying/data-access-abstraction/raw-sql-execution.md) — Implements direct execution of SQL queries with parameter binding for database operations. ([source](https://github.com/xianhu/LearnPython/blob/master/python_sqlalchemy.py))
- [Object-to-Row Mapping](https://awesome-repositories.com/f/data-databases/data-engineering-infrastructure/data-persistence-storage/data-persistence-management/object-to-row-mapping.md) — Links application objects to database table rows to simplify CRUD operations via ORM. ([source](https://github.com/xianhu/LearnPython/blob/master/python_sqlalchemy.py))
- [HTTP Content Retrievers](https://awesome-repositories.com/f/data-databases/data-retrieval-pipelines/http-content-retrievers.md) — Fetches web content via HTTP requests and processes responses as plain text or raw bytes. ([source](https://github.com/xianhu/LearnPython/blob/master/python_requests.py))
- [Data Visualization](https://awesome-repositories.com/f/data-databases/data-visualization.md) — Provides code for generating bar, line, scatter, and pie charts to represent datasets graphically. ([source](https://github.com/xianhu/LearnPython/blob/master/README.md))
- [Database Transaction Management](https://awesome-repositories.com/f/data-databases/database-transaction-management.md) — Demonstrates managing database transactions to ensure atomicity through commits and rollbacks. ([source](https://github.com/xianhu/LearnPython/blob/master/python_sqlalchemy.py))
- [Object-Relational Mapping](https://awesome-repositories.com/f/data-databases/object-relational-mapping.md) — Implements object-relational mapping to link application classes to database schemas for high-level querying.
- [Object-Relational Mapping Models](https://awesome-repositories.com/f/data-databases/object-relational-mapping-models.md) — Defines data models as classes to map application structures to relational database columns and types. ([source](https://github.com/xianhu/LearnPython/blob/master/python_restful_api.py))
- [Relational Databases](https://awesome-repositories.com/f/data-databases/relational-databases.md) — Implements relational database management using both raw SQL queries and object-relational mapping techniques.
- [ORM Implementation Examples](https://awesome-repositories.com/f/data-databases/application-database-management/orm-implementation-examples.md) — Provides examples of mapping application objects to database schemas using object-relational mapping.
- [Animated Visualizations](https://awesome-repositories.com/f/data-databases/data-analysis-visualization/visualization-frameworks-libraries/data-visualization/animated-visualizations.md) — Generates dynamic 2D and 3D data plots that evolve over time via interactive loops. ([source](https://github.com/xianhu/LearnPython/blob/master/python_visual_animation.py))
- [Database Record Querying](https://awesome-repositories.com/f/data-databases/database-record-querying.md) — Provides examples of retrieving, filtering, and modifying database records using an object-relational mapper. ([source](https://github.com/xianhu/LearnPython/blob/master/python_restful_api.py))
- [Data Operations](https://awesome-repositories.com/f/data-databases/object-relational-mappers/active-record-orms/data-operations.md) — Demonstrates how to manage database records using high-level object queries and session management. ([source](https://github.com/xianhu/LearnPython/blob/master/python_sqlalchemy.py))

### Development Tools & Productivity

- [Concurrent Task Execution](https://awesome-repositories.com/f/development-tools-productivity/concurrent-task-execution.md) — Shows how to run multiple functions in parallel using threads and processes to improve performance. ([source](https://github.com/xianhu/LearnPython/blob/master/python_thread_multiprocess.py))

### Graphics & Multimedia

- [Numerical Data Plotting](https://awesome-repositories.com/f/graphics-multimedia/numerical-data-plotting.md) — Generates 2D and 3D charts, including line curves and subplots, using numerical datasets. ([source](https://github.com/xianhu/LearnPython/blob/master/python_visual.py))

### Networking & Communication

- [TCP Socket Clients](https://awesome-repositories.com/f/networking-communication/communication-protocols-architectures/communication-protocols-standards/network-protocols/connection-establishment-protocols/tcp-socket-clients.md) — Implements TCP socket clients to establish connections and exchange text messages with remote servers. ([source](https://github.com/xianhu/LearnPython/blob/master/python_socket.py))
- [TCP Socket Programming](https://awesome-repositories.com/f/networking-communication/tcp-socket-programming.md) — Implements TCP socket servers that listen for incoming network connections and send responses. ([source](https://github.com/xianhu/LearnPython/blob/master/python_socket.py))
- [SMTP Sending](https://awesome-repositories.com/f/networking-communication/smtp-routing/smtp-sending.md) — Connects to mail servers using SSL to send text or HTML messages with attachments via SMTP. ([source](https://github.com/xianhu/LearnPython/blob/master/python_mail.py))

### Operating Systems & Systems Programming

- [Coroutine-Based Asynchronous I/O](https://awesome-repositories.com/f/operating-systems-systems-programming/asynchronous-i-o-libraries/coroutine-based-asynchronous-i-o.md) — Implements asynchronous I/O using coroutines to manage high concurrency without blocking threads.

### Programming Languages & Runtimes

- [Context Managers](https://awesome-repositories.com/f/programming-languages-runtimes/context-managers.md) — Implements resource lifecycle management using context managers to ensure files and connections close correctly.
- [Functional Programming Patterns](https://awesome-repositories.com/f/programming-languages-runtimes/functional-programming-patterns.md) — Demonstrates the use of list comprehensions and lambda functions for complex one-line data transformations. ([source](https://github.com/xianhu/LearnPython/blob/master/python_oneline.py))
- [Asynchronous Streams](https://awesome-repositories.com/f/programming-languages-runtimes/asynchronous-streams.md) — Implements asynchronous generators to produce and process non-blocking data streams. ([source](https://github.com/xianhu/LearnPython/blob/master/python_version36.py))
- [Class Creation Customization](https://awesome-repositories.com/f/programming-languages-runtimes/class-creation-customization.md) — Shows how to intercept and customize class creation using custom metaclasses and type constructors.
- [Dynamic Class Creation](https://awesome-repositories.com/f/programming-languages-runtimes/dynamic-class-creation.md) — Shows how to generate new classes at runtime using type constructors for flexible object structures. ([source](https://github.com/xianhu/LearnPython/blob/master/python_metaclass.py))
- [Function Decorators](https://awesome-repositories.com/f/programming-languages-runtimes/functional-programming-logic/function-decorators.md) — Implements function wrapping to add logging, type checking, and caching without altering original source code. ([source](https://github.com/xianhu/LearnPython/blob/master/python_decorator.py))
- [Multidimensional Arrays](https://awesome-repositories.com/f/programming-languages-runtimes/multidimensional-arrays.md) — Implements examples for creating and managing multi-dimensional grids and matrices for numerical computing. ([source](https://github.com/xianhu/LearnPython/blob/master/python_numpy.py))
- [Python Implementations](https://awesome-repositories.com/f/programming-languages-runtimes/runtime-execution-environments/runtime-environments/runtimes/asynchronous-execution-engines/asynchronous-programming/python-implementations.md) — Provides practical implementations of event loops and coroutines for non-blocking network requests.
- [String and Numeric Formatting](https://awesome-repositories.com/f/programming-languages-runtimes/string-and-numeric-formatting.md) — Demonstrates language-level formatting for strings and numbers to create readable output. ([source](https://github.com/xianhu/LearnPython/blob/master/python_version36.py))
- [String Pattern Replacements](https://awesome-repositories.com/f/programming-languages-runtimes/string-pattern-replacements.md) — Demonstrates how to swap text patterns with replacement strings using Python's string manipulation capabilities. ([source](https://github.com/xianhu/LearnPython/blob/master/python_re.py))
- [String Splitting](https://awesome-repositories.com/f/programming-languages-runtimes/string-splitting.md) — Shows how to divide strings into lists of segments using regular expression delimiters. ([source](https://github.com/xianhu/LearnPython/blob/master/python_re.py))
- [Type Annotations](https://awesome-repositories.com/f/programming-languages-runtimes/type-annotations.md) — Demonstrates the use of type annotations to specify expected data types for better code clarity. ([source](https://github.com/xianhu/LearnPython/blob/master/python_version36.py))

### Software Engineering & Architecture

- [Function Decorators](https://awesome-repositories.com/f/software-engineering-architecture/higher-order-function-wrapping/function-decorators.md) — Provides examples of using function decorators to dynamically extend behavior like logging and type checking.
- [Behavior Customization](https://awesome-repositories.com/f/software-engineering-architecture/architectural-design-patterns/object-oriented-foundations/object-oriented-programming/behavior-customization.md) — Implements special methods to define how objects are compared or represented as strings using standard operators. ([source](https://github.com/xianhu/LearnPython/blob/master/python_magic_methods.py))
- [Producer-Consumer Workflow Managers](https://awesome-repositories.com/f/software-engineering-architecture/producer-consumer-workflow-managers.md) — Implements producer-consumer patterns using synchronized queues to distribute tasks between concurrent workers.
- [Regular Expression-Based Parsing](https://awesome-repositories.com/f/software-engineering-architecture/regular-expression-based-parsing.md) — Uses regular expressions to identify and extract structured data patterns from text strings.
- [Resource Lifecycle Management](https://awesome-repositories.com/f/software-engineering-architecture/resource-lifecycle-management.md) — Uses context managers to ensure resources like files are correctly opened and closed during exceptions. ([source](https://github.com/xianhu/LearnPython/blob/master/python_context.py))
- [Synchronized Queues](https://awesome-repositories.com/f/software-engineering-architecture/synchronized-queues.md) — Provides implementations of synchronized queues to share data between concurrent threads and processes. ([source](https://github.com/xianhu/LearnPython/blob/master/python_thread_multiprocess.py))

### System Administration & Monitoring

- [Asynchronous Event Loops](https://awesome-repositories.com/f/system-administration-monitoring/administrative-operations/linux-system-administration/networking/connection-lifecycle-management/parallel-network-i-o/event-driven-i-o/asynchronous-event-loops.md) — Demonstrates the use of asyncio event loops and coroutines for non-blocking network I/O management.
- [Asynchronous Network Programming](https://awesome-repositories.com/f/system-administration-monitoring/administrative-operations/linux-system-administration/networking/connection-lifecycle-management/parallel-network-i-o/event-driven-i-o/asynchronous-network-programming.md) — Provides comprehensive examples of building non-blocking network clients and servers using event loops.

### Web Development

- [HTTP Request Clients](https://awesome-repositories.com/f/web-development/http-request-clients.md) — Implements HTTP client requests using standard methods to interact with remote web resources. ([source](https://github.com/xianhu/LearnPython/blob/master/python_requests.py))
- [Web Scraping and Automation](https://awesome-repositories.com/f/web-development/web-automation-scraping/web-scraping-automation.md) — Demonstrates extracting data from static and dynamic web pages and automating browser interactions.
- [Web Page Retrievers](https://awesome-repositories.com/f/web-development/web-page-retrievers.md) — Provides utilities for programmatically fetching HTML content from websites for data extraction. ([source](https://github.com/xianhu/LearnPython/blob/master/python_spider.py))
- [Asynchronous Fetching](https://awesome-repositories.com/f/web-development/web-page-retrievers/asynchronous-fetching.md) — Executes multiple concurrent HTTP requests using non-blocking I/O to fetch web pages asynchronously. ([source](https://github.com/xianhu/LearnPython/blob/master/python_coroutine.py))
- [Dynamic Template Rendering](https://awesome-repositories.com/f/web-development/dynamic-template-rendering.md) — Implements dynamic HTML generation by injecting variables into templates with control structures. ([source](https://github.com/xianhu/LearnPython/blob/master/python_flask.py))

### Part of an Awesome List

- [Time and Date](https://awesome-repositories.com/f/awesome-lists/data/time-and-date.md) — Provides examples for parsing, formatting, and manipulating dates and times across different timezones. ([source](https://github.com/xianhu/LearnPython/blob/master/python_datetime.py))
- [Python Visualization](https://awesome-repositories.com/f/awesome-lists/devtools/python-visualization.md) — Includes code samples for statistical plotting and scientific visualization using Python.

### Content Management & Publishing

- [Web Content Scraping](https://awesome-repositories.com/f/content-management-publishing/web-content-scraping.md) — Implements techniques for scraping content from dynamic pages that rely on JavaScript rendering. ([source](https://github.com/xianhu/LearnPython/blob/master/python_splash.py))

### Scientific & Mathematical Computing

- [Array Combinations](https://awesome-repositories.com/f/scientific-mathematical-computing/array-manipulations/array-combinations.md) — Shows how to combine arrays through concatenation and stacking to manage data layouts. ([source](https://github.com/xianhu/LearnPython/blob/master/python_numpy.py))
- [Array Slicing](https://awesome-repositories.com/f/scientific-mathematical-computing/array-manipulations/array-slicing.md) — Provides practical examples of extracting array subsets using coordinate-based indexing and slicing. ([source](https://github.com/xianhu/LearnPython/blob/master/python_numpy.py))
- [Shape Transformations](https://awesome-repositories.com/f/scientific-mathematical-computing/array-manipulations/shape-transformations.md) — Includes examples for reshaping sequences into matrices and transposing axes. ([source](https://github.com/xianhu/LearnPython/blob/master/python_numpy.py))
- [Matrix Operations](https://awesome-repositories.com/f/scientific-mathematical-computing/high-performance-execution-environments/scientific-computing-platforms/scientific-computing/matrix-operations.md) — Implements matrix arithmetic, dot products, and trigonometric functions for numerical analysis. ([source](https://github.com/xianhu/LearnPython/blob/master/python_numpy.py))
- [Statistical Metric Calculators](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/statistics-probability/statistical-analysis-libraries/statistical-metric-calculators.md) — Calculates summary metrics such as means, medians, minimums, and maximums for numerical datasets. ([source](https://github.com/xianhu/LearnPython/blob/master/python_numpy.py))

### Security & Cryptography

- [Automated Login Frameworks](https://awesome-repositories.com/f/security-cryptography/authentication-services/automated-login-frameworks.md) — Automates social media login flows and session management for web scraping purposes. ([source](https://github.com/xianhu/LearnPython/blob/master/python_weibo.py))

### User Interface & Experience

- [Metaclass Definitions](https://awesome-repositories.com/f/user-interface-experience/component-utilities/ui-frameworks/rendering-models/composition-rendering-patterns/component-patterns/class-components/class-decorators/metaclass-definitions.md) — Implements custom metaclasses to intercept class creation and modify structure before instantiation. ([source](https://github.com/xianhu/LearnPython/blob/master/python_metaclass.py))
