Immutable and Mutable Types

Duncan Booth duncan.booth at invalid.invalid
Mon Mar 17 11:40:43 CET 2008

"Diez B. Roggisch" <deets at> wrote:

> Which is exactly what happens - the actual implementation chose to cache
> some values based on heuristics or common sense - but no guarantees are
> made in either way.

Here's a puzzle for those who think they know Python:

Given that I masked out part of the input, which version(s) of Python might 
give the following output, and what might I have replaced by asterisks?

>>> a = 1
>>> b = 5-4
>>> if a is b: print 'yes!'
>>> b = ****
>>> if a is b: print 'yes!'
>>> b
>>> type(b)
<type 'int'>

More information about the Python-list mailing list