On 17Jan2016 14:50, Alex Kleider wrote:
Again, a personal thank you.
No worries.
More often than not, when answering one thing, you teach me about
other things. The 'thing' thing is only the latest. Of course
I knew that using a name bound to a collection would effect the
contents of the c
Again, a personal thank you.
More often than not, when answering one thing, you teach me about
other things. The 'thing' thing is only the latest. Of course
I knew that using a name bound to a collection would effect the
contents of the collection but it would never have occurred to me
to use i
On 17Jan2016 10:49, Alex Kleider wrote:
Can you please clarify the last bit:
"specially recognised as nor in the normal domain for that value."
s/nor/not/
May I trouble you further by specifically asking about 's/nor/not/'- I don't
get what that's about.
Ah. Ed, sed, vi, vim speak. Substi
Alex Kleider writes:
> May I trouble you further by specifically asking about 's/nor/not/'- I
> don't get what that's about.
He's using a common editor syntax (the ancient ‘ed’ editor's
“substitute” command, which is inherited by Unix ‘sed’ and ‘vi’, among
others) to represent “please replace th
On 2016-01-17 02:18, Cameron Simpson wrote:
On 16Jan2016 22:42, Alex Kleider wrote:
On 2016-01-16 18:02, Cameron Simpson wrote:
much like writing a function "def f(x, y=None)"; None is a sentinel
value - specially recognised as nor in the normal domain for that
value.
Can you please clarify
boB Stepp wrote:
>> The hard part is to remember to test whenever a negative index is
>> calculated.
>
> I am assuming that this is relevant to what just came before, the use
> of this "or None" check. Is this correct?
No, I mean that you always should test your code against the corner cases.
Steven D'Aprano wrote:
>> Slightly related is a problem that comes up in practice; you cannot
>> specify "including the last item" with negative indices:
>
> But you can do so by leaving the end index blank:
That's why the problem typically comes up when the stop index is a variable.
__
On 16Jan2016 22:42, Alex Kleider wrote:
On 2016-01-16 18:02, Cameron Simpson wrote:
much like writing a function "def f(x, y=None)"; None is a sentinel
value - specially recognised as nor in the normal domain for that
value.
Can you please clarify the last bit:
"specially recognised as nor in
On 17/01/16 00:23, Alex Kleider wrote:
>> I should have added a :-/ to that in case it wasn't obvious...
>
> It wasn't to me; could you please explain what you mean by ":-/" and/or
> where you should have added it?
It's an emoticon
I usually use it as being tongue in cheek, but I see that
wikip
On Sat, Jan 16, 2016 at 04:39:09PM -0600, boB Stepp wrote:
> So in this model of understanding negative list indexing, should it be:
>
> mylist = [ 100, 200, 300, 400, 500 ]
> ^^^^^ ^
> -5 -4 -3 -2 -1 ?
Correct.
> Well, it has to be this; otherwise
On Sat, Jan 16, 2016 at 01:19:16PM +0100, Peter Otten wrote:
> Steven D'Aprano wrote:
>
> > But slices are slightly different. When you provide two indexes in a
> > slice, they mark the gaps BETWEEN items:
>
> The other explanation that Python uses half-open intervals works for me.
Half-open a
On 2016-01-16 18:02, Cameron Simpson wrote:
On 16Jan2016 18:43, boB Stepp wrote:
This led me to try:
mylist[:None]
[100, 200, 300, 400, 500]
So, in effect, None is acting as a place holder for that final
position in slices. Also, I would never have thought to be able to
use a logical "or"
On 16Jan2016 18:43, boB Stepp wrote:
This led me to try:
mylist[:None]
[100, 200, 300, 400, 500]
So, in effect, None is acting as a place holder for that final
position in slices. Also, I would never have thought to be able to
use a logical "or" inside an index in Peter's "[:-i or None]".
Alex sent me this off-list. I hope he does not mind me sharing part
of what he wrote on-list!
On Sat, Jan 16, 2016 at 4:57 PM, Alex Kleider wrote:
> On 2016-01-16 14:39, boB Stepp wrote:
>
>
> mylist[:0 or None]
>>
>> [100, 200, 300, 400, 500]
>>
>> The critical portion of the for loop for m
On 2016-01-16 16:08, Alan Gauld wrote:
On 16/01/16 23:56, Alan Gauld wrote:
On 16/01/16 22:39, boB Stepp wrote:
So in this model of understanding negative list indexing, should it
be:
mylist = [ 100, 200, 300, 400, 500 ]
^^^^^ ^
-5 -4 -3 -2 -1 ?
On 16/01/16 23:56, Alan Gauld wrote:
> On 16/01/16 22:39, boB Stepp wrote:
>
>> So in this model of understanding negative list indexing, should it be:
>>
>> mylist = [ 100, 200, 300, 400, 500 ]
>> ^^^^^ ^
>> -5 -4 -3 -2 -1 ?
>>
>> Well, it has to be
boB Stepp writes:
> So in this model of understanding negative list indexing, should it be:
>
> mylist = [ 100, 200, 300, 400, 500 ]
> ^^^^^ ^
> -5 -4 -3 -2 -1 ?
For completeness, let's use the rest of the integers also::
012
On 16/01/16 22:39, boB Stepp wrote:
> So in this model of understanding negative list indexing, should it be:
>
> mylist = [ 100, 200, 300, 400, 500 ]
> ^^^^^ ^
> -5 -4 -3 -2 -1 ?
>
> Well, it has to be this; otherwise, the off-by-one error exist.
On Sat, Jan 16, 2016 at 6:19 AM, Peter Otten <__pete...@web.de> wrote:
> Steven D'Aprano wrote:
>
>> But slices are slightly different. When you provide two indexes in a
>> slice, they mark the gaps BETWEEN items:
>
> The other explanation that Python uses half-open intervals works for me.
>
>> Now
Steven D'Aprano wrote:
> But slices are slightly different. When you provide two indexes in a
> slice, they mark the gaps BETWEEN items:
The other explanation that Python uses half-open intervals works for me.
> Now, what happens with *negative* indexes?
>
> mylist = [ 100, 200, 300, 400, 500
On Fri, Jan 15, 2016 at 10:20:41PM -0600, boB Stepp wrote:
> At
> https://docs.python.org/3.4/library/stdtypes.html#sequence-types-list-tuple-range
> it states:
>
> "s.insert(i, x) inserts x into s at the index given by i (same as s[i:i] =
> [x])"
>
> I find this confusing.
That's because it i
On Fri, Jan 15, 2016 at 11:32 PM, Cameron Simpson wrote:
> On 15Jan2016 23:05, boB Stepp wrote:
>>
>> On Fri, Jan 15, 2016 at 10:53 PM, Cameron Simpson wrote:
>>>
>>> things.insert(-1, 'What the heck?!?')
>>> things
[0, 'Hmm...', 3, 'WhackABunny', 6, 'What the heck?!?'
On 15Jan2016 23:05, boB Stepp wrote:
On Fri, Jan 15, 2016 at 10:53 PM, Cameron Simpson wrote:
things.insert(-1, 'What the heck?!?')
things
[0, 'Hmm...', 3, 'WhackABunny', 6, 'What the heck?!?', '?']
"...at the index..." to me would mean that 'What the heck?!?' should
become the last item in
On Fri, Jan 15, 2016 at 10:53 PM, Cameron Simpson wrote:
> On 15Jan2016 22:20, boB Stepp wrote:
>> I always get an empty list, which is actually what I was expecting, so
>> I do not see how s[i:i] can ever equal [x].
>
>
> It isn't an equality test (==), it is an assignent. It is saying "set the
On 15Jan2016 22:20, boB Stepp wrote:
At
https://docs.python.org/3.4/library/stdtypes.html#sequence-types-list-tuple-range
it states:
"s.insert(i, x) inserts x into s at the index given by i (same as s[i:i] = [x])"
I find this confusing. First, at the interpreter, whenever I type in:
things
At
https://docs.python.org/3.4/library/stdtypes.html#sequence-types-list-tuple-range
it states:
"s.insert(i, x) inserts x into s at the index given by i (same as s[i:i] = [x])"
I find this confusing. First, at the interpreter, whenever I type in:
>>> things
[0, 'Hmm...', 3, 'WhackABunny', 6, '
26 matches
Mail list logo