SShortSingh.
Back to feed

How Python's '=' operator works: assignment vs. mutation explained

0
·23 views

A tutorial published on DEV Community explains a common source of confusion for Python beginners: why assigning one variable to another can sometimes cause both to change. The key distinction is that '=' in Python does not copy an object — it binds a name to an existing object, meaning two variables can point to the same mutable structure like a list. When a mutable object is modified through one variable, the change is visible through all other variables referencing the same object, a behavior known as mutation. By contrast, reassigning a variable to a new value simply rebinds that name to a different object, leaving other references unaffected. The article also covers related pitfalls, including the difference between '=' and '==' and the fact that Python's input() function always returns a string, not a number.

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
ProgrammingHacker News ·

AMD Details Zen 6 Family Focus on Feeding Its Cores

A Chips and Cheese analysis examines AMD's upcoming Zen 6 processor family and how it is designed to keep its execution cores supplied with data. The piece centers on the memory and cache subsystem, which determines how effectively the processor avoids stalls. It is drawn from a technical write-up posted to Hacker News, where it gathered modest early attention. The source provides only the article link and discussion metrics, so specific architectural figures are not reflected in this summary.

0
ProgrammingDEV Community ·

Store Timestamps in UTC and Display Them in Local Time

A CRM entry showing only '10:30' can be misread by staff in different timezones because it does not indicate which zone it represents. The article distinguishes between instants, such as an enquiry acceptance time, which should be stored in UTC or a timezone-aware type, and local scheduling intentions, which need a local date, time, and IANA timezone identifier. It recommends converting instants to a documented display timezone with a locale-aware formatter and labeling the zone where confusion is possible. Recurring schedules must preserve timezone rules because fixed UTC offsets fail to account for daylight-saving changes, and ambiguous or nonexistent local times should be handled by a documented policy. The author also advises keeping event occurrence, receipt, and next-attempt times as separate fields and testing edge cases such as daylight-saving transitions and invalid dates.

0
ProgrammingDEV Community ·

Answering Claude Code and Codex prompts from your phone

Coding agents like Claude Code and Codex pause and wait for approval when they need permission to run a command, which can stall work if you're away from your computer. Claude Code offers a built-in Remote Control feature, started with /remote-control in a session and accessed through the Claude app or claude.ai/code, but it requires a paid plan and an active terminal process. Codex is set up through the ChatGPT desktop app's Control this Mac or PC option, paired to your phone via QR code and answered in the ChatGPT mobile app. For any agent, an alternative is enabling SSH on the computer and attaching to a tmux session from a phone terminal app. All these methods require the host computer to stay awake and online, and each agent has its own separate setup.

0
ProgrammingHacker News ·

Neil Fraser Reports the .name Domain Has Been Grandfathered

A post on neil.fraser.name, dated November 10, 2026, discusses the status of the .name top-level domain as having been grandfathered. The item was shared on Hacker News, where it received 26 points and 3 comments. The source text available is limited to the link and discussion metadata, so the full details of the grandfathering decision are not confirmed here. Readers are directed to the original post for the author's complete account.