[Tutor] s.insert(i, x) explanation in docs for Python 3.4 confusing to me

Alex Kleider akleider at sonic.net
Sun Jan 17 01:42:01 EST 2016


On 2016-01-16 18:02, Cameron Simpson wrote:
> On 16Jan2016 18:43, boB Stepp <robertvstepp at gmail.com> 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]".
> 
> Yah, like the default value for many missing parameters. When you
> don't need an expression after the ":" you can of course write:
> 
>  mylist[:]
> 
> 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 the normal domain for that value."

thanks,
Alex


More information about the Tutor mailing list