SShortSingh.
Back to feed

How Python Automatically Passes 'self': The Descriptor Protocol Explained

0
·1 views

Every Python programmer calls instance methods without manually passing 'self', but few understand why it works. When Python evaluates an attribute like obj.hello, it does not simply retrieve a function — it triggers the descriptor protocol, which transforms the function into a bound method object. This bound method holds a reference to the instance, so when the method is called, the instance is automatically supplied as the first argument. The equivalence of obj.hello() and Demo.hello(obj) reveals this internal mechanism at work. A developer exploring Python internals has documented this process in detail, with experiments and code examples published in a public GitHub repository.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

How NGINX Acts as a Gateway to Route Traffic Between Docker Containers

In a typical containerised web application, NGINX serves as the sole internet-facing entry point, routing incoming browser requests to the appropriate internal Docker containers. When a user visits a site, DNS resolves the domain to the server's public IP, and NGINX receives the request before any other service does. Requests to the root path are forwarded to the frontend container, while paths beginning with '/api' are directed to the backend service. The backend processes logic and queries a PostgreSQL database, which remains entirely hidden from the public internet. This architecture keeps internal services isolated within Docker's private network, improving both security and maintainability.

0
ProgrammingDEV Community ·

How a 10-Minute Post-Call Follow-Up Can Help Freelancers Win Client Renewals

A structured follow-up sent within an hour of a client call can significantly improve a freelancer's chances of contract renewal, according to a piece published on DEV Community. The recommended format includes a three-line call recap, a simple action table listing tasks with owners and deadlines, and a single clear next step. The rationale is that clients rarely leave over poor work quality — they leave because they feel uninformed and anxious about project progress. A concise follow-up addresses that anxiety by demonstrating organization and clarity. The author also notes that automating this process can help freelancers stay consistent, especially during busy periods.

0
ProgrammingDEV Community ·

Free browser-based subtitle tools let you convert and edit SRT/VTT files privately

A developer has launched a free suite of subtitle utilities under the project Lazyblink, designed to run entirely in the browser without uploading files to any server. The toolset supports SRT and VTT format conversion, plain-text transcript extraction, and caption timing adjustments to fix sync issues. Because all processing is handled client-side via JavaScript, no backend infrastructure is required and files never leave the user's device. The developer built the tools to address common frustrations with existing online subtitle services, which often require signups, add watermarks, or store user files remotely. The tools are available at lazyblink.com/subtitle-tools with no registration or cost required.