DEV Community

豌豆花下猫
豌豆花下猫

Posted on

Python Trending Weekly #42 (2024-03-16)

Welcome to the Python Trending Weekly, a weekly newsletter about Python, AI and general programming techniques, with the majority links in English and a small portion in Chinese.

The original version of the weekly was written in Chinese. What you are reading here is mostly translated by LLMs.

Substack Channel : Click to subscribe

🦄Articles & Tutorials

  1. Why Our Company Still Uses Python for Project Development?

This article gave me a sense of "industry secrets you don't know." Small companies are still sticking with Python 2.7 + Django 1.8, and they are supporting hundreds of millions of dollars in transactions each year. The author also shared several projects, and my feeling is: Maybe you don't need to consider "which language is better" too much. Just choose the one you are familiar with and focus on business implementation.

  1. Should Python Strings Use Single or Double Quotes?

Python strings allow both single and double quotes, and even triple quotes. This flexibility is great, but it's also a source of conflict for standards pedants. This article shares an interesting story about it, recommended reading!

  1. Understanding Context Manager and Its Syntactic Sugar

Why do we need context managers? What problems do they solve? The article also introduces the context manager protocol, the with syntax sugar, implementing context managers with contextlib, and four practical use cases.

  1. Python deque tutorial

A deque is a double-ended queue data structure in the collections module, similar to a list but optimized for fast addition and removal from either end. This tutorial covers its basic usage and some advanced use cases.

  1. Python Generic function and class types

Python performs type checking at runtime and emphasizes the behavior of objects rather than their types, so it doesn't put much emphasis on "generics" that focus on type safety. However, Python does support generics, and this article introduces how to implement generic functions and generic classes using the typing module.

  1. Gevent in practice: Common pitfalls to keep in mind

Gevent is a high-performance networking library built on top of greenlet, a lightweight coroutine implementation. This article introduces common pitfalls of Gevent and provides solutions.

  1. Insecurity and Python pickles

pickle is Python's standard library for serialization, but it has a major security risk when deserializing! The article introduces how it works, the root of the security risk, and how the machine learning community collaborated to design a safer alternative format called safetensors.

  1. Building An Open Source Decentralized E-Book Search Engine

This tutorial uses JavaScript and Python to develop an e-book search engine that relies on Glitter (a decentralized database service built with Tendermint) and uses React to develop the page that displays the search results.

  1. What's the Difference Between Python import and Java import?

Many programming languages have the import keyword, and their functions are similar, but what are the differences in their underlying mechanisms? This article analyzes the similarities and differences between import in Java and Python, which can deepen your understanding of this topic.

  1. PDM's Internal Implementation (1)

pdm is an excellent dependency management tool in Python, created by the Chinese developer @frostming. The author plans to write a series of articles about its internal implementation. This is the first article, which introduces what Lockfile is and how Lockfile is generated.

  1. Does Python have pointers?

Does Python have pointers? The answer depends on how you understand "pointers". The author gives a brief but insightful answer. Python does not have the classic pointer operations of the C language, but every variable in Python is a pointer, i.e., everything is an implicit pointer. (In addition: A project "brings the pointer hell to Python", which is as superfluous as the Python version with curly braces below.)

  1. When Python can’t thread: a deep-dive into the GIL’s impact

The GIL-less feature was finally merged into Python's main branch this week! Here is a long article that provides an in-depth introduction to the GIL, helping to understand how the GIL works and predict where concurrency bottlenecks are located. The article uses many thread timing analysis graphs for easy understanding.

🎁 Python Trending Weekly 🎁 organizes its content into seasons, with every 30 issues forming a season. The highlights from the first season have been compiled for your convenience. You can access them online here (Chinese).

🐿️Projects & Resources

  1. Flet enables developers to easily build realtime web, mobile and desktop apps in Python

No front-end experience required, quickly build cross-platform, multi-user, real-time single-page applications (SPAs); no SDK needed, development can be done with an IDE or text editor, front-end uses Flutter UI, back-end currently supports Python, with plans to support Go and C#. (8.7K stars) (Contributed by @bear)

  1. ss-python: A Python project template covering the entire development lifecycle

A Python project template with various integrations, configurations, and modules, featuring: project setup and template updates with copier, dependency and virtual environment management with pdm, containerization with dev container, mypy, ruff, and other commonly used tech stacks. (Contributed by @huxuan_org)

  1. dukpy: Simple JavaScript interpreter for Python

A JS interpreter built on the duktape engine, used to execute JS code in Python. It has no other external dependencies, and has built-in common transpilers (TypeScript, JSX, LESS, CoffeeScript). It also supports passing parameters, running multiple scripts, global interpreters, loading modules using require, and installing packages from npmjs.org.

>>> import dukpy
>>> dukpy.evaljs("var o = {'value': 5}; o['value'] += 3; o")
{'value': 8}
Enter fullscreen mode Exit fullscreen mode
  1. PyKidos: A Python Programming Practice Website

An online Python programming website that makes it easy to teach kids how to code through games.

  1. hatchet: A distributed, fault-tolerant task queue

Replaces hard-to-manage traditional queues and pub/sub systems, supports fault recovery, and solves concurrency, fairness, and rate limiting issues. Features low latency and high throughput, supports strategies like FIFO, LIFO, round-robin, and priority queues, allows for customizable retry policies, and supports integrated error handling. (2.4K stars)

  1. full-stack-fastapi-template: Full stack, modern web application template

Supports JWT authentication, email-based password recovery, and uses Traefik as a reverse proxy/load balancer, with FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS, etc. (17.5K stars)

  1. bython: Python with braces

I think Python's use of whitespace for indentation is its most beautiful design feature! But some people prefer curly braces. This project adds curly braces to Python, with a basic example:

def print_message(num_of_times) {
    for i in range(num_of_times) {
        print("Bython is awesome!");
    }
}

if __name__ == "__main__" {
    print_message(10);
}
Enter fullscreen mode Exit fullscreen mode
  1. treq: Python requests-like API built on top of Twisted's HTTP client

A simple, requests-like HTTP client built on top of Twisted.

  1. JavSP: Video Metadata Scraper Aggregating Data from Multiple Sites

Automatically fetches, aggregates, and categorizes video files based on specified rules, creating metadata files for use with software like Emby, Jellyfin, Kodi, etc. (1.6K stars)

  1. botasaurus: The All in One Framework to build Awesome Scrapers

Access Cloudflare protected pages with simple HTTP requests, the only scraper framework with SSL support for authenticated proxies, integrate any Chrome extension with just one line of code, sitemap support, data cleaning support, caching support, provides Selenium shortcuts, and more.

  1. pywebview: Build GUI for your Python program with JavaScript, HTML, and CSS

A lightweight cross-platform wrapper around the WebView component, displaying HTML content in a GUI window. Can be used with web frameworks or standalone to bridge Python with the DOM. The latest 5.0 release introduces Android support. (4.2K stars)

  1. Paper-Piano: Piano like no other, Piano on Paper

Allows you to practice playing the piano directly on a sheet of paper! Currently supports up to two fingers, primarily intended for those who cannot afford a piano.

Image of Paper-Piano

🐼Subscribe Welcome

  • Blog: Explore my independent blog where you can find a collection of original/translated technical articles over the years, along with some reflections since 2009.
  • Newsletter: Subscribe to my channel on Substack for a curated newsletter delivered straight to your inbox, keeping you updated on current affairs.
  • Github: Access the Markdown source files of this weekly digest on Github and feel free to use them for anything you have in mind!
  • Telegram: Beyond notifications for the weekly digest, I consider it an "extra edition," providing additional, more diverse information.
  • Twitter: Follow me on Twitter where my feed is filled with numerous accounts of developers and organizations in the Python community.

Top comments (0)