object types, mutable or not?
Ben Finney
ben+python at benfinney.id.au
Mon May 14 19:19:48 EDT 2018
Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:
> Five years ago, the President Of the United States of America, or POTUS
> for short, referred to Barrack Obama. Today, it refers to Donald Trump.
> This didn't happen by mutating a single person (an object) from a
> youngish black-skinned man to an oldish orange-skinned man. It happened
> by re-assigning the name from Obama to Trump.
This is a good analogy.
> Likewise when you re-assign a variable name from one value (an object) to
> another, the original object doesn't change. You just make the name refer
> to a different object, while the first goes on its merry way (probably to
> be collected by the garbage collector and the memory reclaimed).
Hopefully I am not the only one who wondered how closely the analogy to
POTUS extends into this description.
--
\ “I can picture in my mind a world without war, a world without |
`\ hate. And I can picture us attacking that world, because they'd |
_o__) never expect it.” —Jack Handey |
Ben Finney
More information about the Python-list
mailing list