string slicing

Ishwor ishwor.gurung at gmail.com
Sun Dec 5 09:39:55 EST 2004


Hello all ,
  I am trying some interactive examples here where i have come across
inconsistencies??? :O
Anyway heres whats bothering me

>>> s = 'hello'
>>> s[0]
'h'
>>> s[:]
'hello'
>>> m = s[:]
>>> m
'hello'
>>> m is s
True

 I discussed the *is* operator with some of the pythoners before as
well but it is somewhat different than what i intended it to do. The
LP2E by Mark & David says -
" m gets a *full top-level copy* of a sequence object- an object with
the same value but distinct piece of memory." but when i test them
with *is* operator then the result is True. Why is this happening??
Any help is appreciated.. Thanx


-- 
cheers,
Ishwor Gurung



More information about the Python-list mailing list