On Aug 6, 8:15 am, "Rhodri James" <rho...@wildebst.demon.co.uk> wrote:
> On Thu, 05 Aug 2010 17:07:53 +0100, wheres pythonmonks  
>
> <wherespythonmo...@gmail.com> wrote:
> > Well, I am not convinced of the equivalence of not None and true:
[snip]
> >>> "spam, eggs, chips and spam" is "spam, eggs, chips and spam"
> True
> >>> a = "spam, eggs, chips and spam"
> >>> b = "spam, eggs, chips and spam"
> >>> a is b
> False

but:

>>> a = "hello"
>>> b = "hello"
>>> a is b
True

Ooh, that looks dangerous. Are they the same object?

>>> a += "o"
>>> a
'helloo'
>>> b
'hello'

Phew.

(Python does not make two copies of small strings until it needs to).

Matt.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to