Re: [Tutor] Philosophical question about string slicing from end of a string

2014-11-24 Thread Zachary Ware
On Mon, Nov 24, 2014 at 12:32 PM, boB Stepp robertvst...@gmail.com wrote: Python 2.7.8 Win7Pro str = 0123456789 str[-1] '9' str[-3:-1] '78' str[-3:] '789' I understand that the above is the way it is in Python, but I am puzzled why the designers did not choose that str[-3:-1] returns

Re: [Tutor] Philosophical question about string slicing from end of a string

2014-11-24 Thread boB Stepp
On Mon, Nov 24, 2014 at 12:57 PM, Zachary Ware zachary.ware+py...@gmail.com wrote: [...] Have I clarified or muddied it for you? :) Clarified, I believe, if my following statements are correct: I did not consider that the behavior was symmetric with positive indices. So, index 0 is the center

Re: [Tutor] Philosophical question about string slicing from end of a string

2014-11-24 Thread boB Stepp
On Mon, Nov 24, 2014 at 1:06 PM, boB Stepp robertvst...@gmail.com wrote: On Mon, Nov 24, 2014 at 12:57 PM, Zachary Ware zachary.ware+py...@gmail.com wrote: [...] Have I clarified or muddied it for you? :) Clarified, I believe, if my following statements are correct: I did not consider that

Re: [Tutor] Philosophical question about string slicing from end of a string

2014-11-24 Thread Zachary Ware
On Mon, Nov 24, 2014 at 1:06 PM, boB Stepp robertvst...@gmail.com wrote: On Mon, Nov 24, 2014 at 12:57 PM, Zachary Ware zachary.ware+py...@gmail.com wrote: [...] Have I clarified or muddied it for you? :) Clarified, I believe, if my following statements are correct: I did not consider that

Re: [Tutor] Philosophical question about string slicing from end of a string

2014-11-24 Thread Steven D'Aprano
On Mon, Nov 24, 2014 at 12:32:27PM -0600, boB Stepp wrote: Python 2.7.8 Win7Pro str = 0123456789 str[-1] '9' str[-3:-1] '78' str[-3:] '789' I understand that the above is the way it is in Python, but I am puzzled why the designers did not choose that str[-3:-1] returns '789',

Re: [Tutor] Philosophical question about string slicing from end of a string

2014-11-24 Thread eryksun
On Mon, Nov 24, 2014 at 1:33 PM, Zachary Ware zachary.ware+py...@gmail.com wrote: Also note that there's no way to get the last member with a negative second index. Also note that, given a -1 step, there's no way to get the first member with a non-negative second index. s[-1:0:-1]