string slicing

2004-12-05 Thread Ishwor
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

Re: string slicing

2004-12-05 Thread Kent Johnson
Ishwor wrote: s = 'hello' m = s[:] 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 bu

Re: string slicing

2004-12-05 Thread Ishwor
On Sun, 05 Dec 2004 09:44:13 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote: [snip] > > This behaviour is due to the way strings are handled. In some cases strings > are 'interned' which > lets the interpreter keep only a single copy of a string. If you try it with > a list you get a > differen

Re: string slicing

2004-12-05 Thread Kent Johnson
Ishwor wrote: On Sun, 05 Dec 2004 09:44:13 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote: This behaviour is due to the way strings are handled. In some cases strings are 'interned' which lets the interpreter keep only a single copy of a string. If you try it with a list you get a different result

Re: string slicing

2004-12-05 Thread Fredrik Lundh
Ishwor wrote: > I am trying some interactive examples here where i have come across > inconsistencies??? :O obsession with implementation artifacts is a premature optimization, and should be avoided. > Anyway heres whats bothering me > s = 'hello' s[0] > 'h' s[:] > 'hello' m

Re: string slicing

2004-12-05 Thread Josiah Carlson
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > > Ishwor wrote: > > > I am trying some interactive examples here where i have come across > > inconsistencies??? :O > > obsession with implementation artifacts is a premature optimization, > and should be avoided. [snip] > a suggestion: if you rea

Re: string slicing

2004-12-05 Thread Ishwor
On Sun, 05 Dec 2004 10:31:12 -0800, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > > a suggestion: if you really want to be productive in python, forget about > > "is" for a while. I know what Fredrik means here (Thanx Frederick :) ) but IMHO if the pa

Re: string slicing

2004-12-05 Thread Josiah Carlson
Ishwor <[EMAIL PROTECTED]> wrote: > > On Sun, 05 Dec 2004 10:31:12 -0800, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > > > "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > > > > a suggestion: if you really want to be productive in python, forget about > > > "is" for a while. > > I know what Fredr

Re: string slicing

2004-12-05 Thread Ishwor
I didn't mean to be extremely rude. Just a little bit..~:-). sorry. On Sun, 05 Dec 2004 12:09:22 -0800, Josiah Carlson <[EMAIL PROTECTED]> wrote: > [snip] > > Goodness, you got right snippy with the 'intellectual property' thing. > I'm sorry if it sounded as if I had meant "I came up with this

Re: string slicing

2004-12-05 Thread Carlos Ribeiro
On Sun, 5 Dec 2004 17:07:47 +0100, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > a suggestion: if you really want to be productive in python, forget about > "is" for a while. good code doesn't copy stuff much, either, by the way. > python's all about objects, and things that hold references to object

Concantenation and string slicing

2006-02-23 Thread DannyB
I've written a program that takes a phrase and spits it back out backwards. My problem is it throws each character on a new line. I'd like the phrase to be on the same line. Is this possible? #Backward Message message = raw_input("Enter a message: ") letter = len(message) while (letter > 0):

Re: Concantenation and string slicing

2006-02-23 Thread nak
add a dash like shown below >>> print newMessage, -- http://mail.python.org/mailman/listinfo/python-list

Re: Concantenation and string slicing

2006-02-23 Thread DannyB
Wow - thats simple =). Thanks a ton!! -- http://mail.python.org/mailman/listinfo/python-list

Re: Concantenation and string slicing

2006-02-23 Thread CatDude
On Thu, 23 Feb 2006 14:55:16 -0800, DannyB wrote: > I've written a program that takes a phrase and spits it back out > backwards. My problem is it throws each character on a new line. I'd > like the phrase to be on the same line. Is this possible? First suggestion: Put a comma at the end of th

Re: Concantenation and string slicing

2006-02-23 Thread Larry Bates
DannyB wrote: > I've written a program that takes a phrase and spits it back out > backwards. My problem is it throws each character on a new line. I'd > like the phrase to be on the same line. Is this possible? > > #Backward Message > > message = raw_input("Enter a message: ") > letter = len

Re: Concantenation and string slicing

2006-02-25 Thread Larry Bates
Dennis Lee Bieber wrote: > On Thu, 23 Feb 2006 18:06:46 -0600, Larry Bates > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > >> Better was is: >> >> message = raw_input("Enter a message: ") >> print message[::-1] >> > > I sometimes get the feeling a lot of responses t