MikeTrendsTrends right now

Mmastodon TechnologySoftware first seen 24 d ago, last 24 d ago, peak #12

Python's import semantics trip up developers

Original: Fun with Python: from mod import X imports the **value** of mod.X and binds it to a variable named X in the importing mo

A programmer is highlighting a common Python misunderstanding: 'from mod import X' copies the value of mod.X into a new local variable, so reassigning X in the importing module does not change mod.X. The two remain separate bindings, and the original module attribute stays untouched unless you import the module itself and modify the attribute directly.

Why now: Developers frequently hit this confusion and share explanations of Python's import behaviour online.

Python

Open on mastodon →

Evidence

API: https://socialmediatrends-api.osmike.com/v1/trends/2764936