Re: String slices

2019-08-12 Thread Rhodri James
On 10/08/2019 10:45, Peter J. Holzer wrote: On 2019-08-10 09:10:12 +1000, Cameron Simpson wrote: On 09Aug2019 22:28, Paul St George wrote: On 09/08/2019 16:29, Rhodri James wrote: (Actually I would probably use outstream.write() and do my own formatting, but let's not get side-tracked ;-) I

Re: Re: String slices

2019-08-10 Thread Paul St George
On 10/08/2019 17:35, Dennis Lee Bieber wrote: On Sat, 10 Aug 2019 11:45:43 +0200, "Peter J. Holzer" declaimed the following: There are of course many variants to all three methods. And then one can get downright nasty... X = 3.14 Y = 2.78 Z = 6.226E23 print("".join(["Plane rotation

Re: String slices

2019-08-10 Thread Peter J. Holzer
On 2019-08-10 09:10:12 +1000, Cameron Simpson wrote: > On 09Aug2019 22:28, Paul St George wrote: > > On 09/08/2019 16:29, Rhodri James wrote: > > > (Actually I would probably use outstream.write() and do my own > > > formatting, but let's not get side-tracked ;-) > > > > > I would love to hear yo

Re: String slices

2019-08-09 Thread Cameron Simpson
On 09Aug2019 22:28, Paul St George wrote: On 09/08/2019 16:29, Rhodri James wrote: The 'sep="\n"' parameter to print() means "put a newline between each item."  So don't do that.  Put the newlines you do want in explicitly, or use separate calls to print(): (I'm abbreviating because I really

Re: Re: String slices

2019-08-09 Thread Paul St George
On 09/08/2019 16:29, Rhodri James wrote: On 09/08/2019 15:13, Paul St George wrote: In the code (below) I want a new line like this: Plane rotation X: 0.0 Plane rotation Y: 0.0 Plane rotation Z: 0.0 But not like this: Plane rotation X: 0.0 Plane rotation Y: 0.0 Plane rotation Z: 0.0 Is it p

Re: String slices

2019-08-09 Thread Peter Otten
Paul St George wrote: > In the code (below) I want a new line like this: > > Plane rotation X: 0.0 > Plane rotation Y: 0.0 > Plane rotation Z: 0.0 > > But not like this: > > Plane rotation X: > 0.0 > Plane rotation Y: > 0.0 > Plane rotation Z: > 0.0 > > Is it possible? > print( > > "Plane ro

Re: String slices

2019-08-09 Thread Rhodri James
On 09/08/2019 15:13, Paul St George wrote: In the code (below) I want a new line like this: Plane rotation X: 0.0 Plane rotation Y: 0.0 Plane rotation Z: 0.0 But not like this: Plane rotation X: 0.0 Plane rotation Y: 0.0 Plane rotation Z: 0.0 Is it possible? (I am using Python 3.5 within Blen

Re: String slices

2019-08-09 Thread Dan Sommers
On 8/9/19 10:13 AM, Paul St George wrote: In the code (below) I want a new line like this: Plane rotation X: 0.0 Plane rotation Y: 0.0 Plane rotation Z: 0.0 But not like this: Plane rotation X: 0.0 Plane rotation Y: 0.0 Plane rotation Z: 0.0 Is it possible? (I am using Python 3.5 within Blend

RE: String slices work only for first string character ?

2008-12-16 Thread Barak, Ron
Thanks to all who pointed my wrong understanding of how string slices are defined. Bye, Ron. From: Barak, Ron [mailto:ron.ba...@lsi.com] Sent: Tuesday, December 16, 2008 15:35 To: python-list@python.org Subject: String slices work only for first string character ?

RE: String slices work only for first string character ?

2008-12-16 Thread Barak, Ron
Hi Mr. Cain, Mae culpa: obviously, I erroneously understood the number after the ':' as the string length. Thanks, Ron. -Original Message- From: D'Arcy J.M. Cain [mailto:da...@druid.net] Sent: Tuesday, December 16, 2008 15:45 To: Barak, Ron Cc: python-list@python.org Subj

Re: String slices work only for first string character ?

2008-12-16 Thread D'Arcy J.M. Cain
On Tue, 16 Dec 2008 13:35:27 + "Barak, Ron" wrote: > Can any one explain why the following string slice works only for the first > character, but not for any other ? I think that you need to reread the docs on slices. > print "|"+data[0:1]+"|" > print "|"+data[1:1]+"|" If you want the seco

Re: String slices work only for first string character ?

2008-12-16 Thread Tim Chase
Can any one explain why the following string slice works only for the first character, but not for any other ? $ cat /tmp/tmp.py #!/usr/bin/env python data = 'F0023209006-0101' print data print "|"+data[0:1]+"|" print "|"+data[1:1]+"|" print "|"+data[2:1]+"|" $ python `cygpath -w /tmp/tmp.py`