on slices, negative indices, which are the equivalent procedures?
Jack Brandom
jbrandom at example.com
Sat Aug 14 23:05:29 EDT 2021
Dennis Lee Bieber <wlfraed at ix.netcom.com> writes:
> On Wed, 11 Aug 2021 11:59:11 -0300, Jack Brandom <jbrandom at example.com>
> declaimed the following:
>
>>
>>Where are these production rules coming from? They're not at
>>
>> https://docs.python.org/3/reference/grammar.html
>>
>>The word ``stride'' doesn't appear in this grammar.
>
> Possibly from older versions of the grammar, before simplification to
> just <expression>. Originally, the "stride" term was added in response to
> requests from the numerical library developers (NumPy seems to be the
> survivor of that cluster). At the time, it wasn't envisioned to be usable
> with regular Python objects.
>
> https://en.wikipedia.org/wiki/Array_slicing#1991:_Python
> """
> The stride syntax (nums[1:5:2]) was introduced in the second half of the
> 1990s, as a result of requests put forward by scientific users in the
> Python "matrix-SIG" (special interest group).
> """
Always great to know the history with good references. Thanks very much.
> As for the grammar... Would you prefer that from 2.7?
>
> trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
> subscriptlist: subscript (',' subscript)* [',']
> subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop]
> sliceop: ':' [test]
>
> test: or_test ['if' or_test 'else' test] | lambdef
> or_test: and_test ('or' and_test)*
> and_test: not_test ('and' not_test)*
> not_test: 'not' not_test | comparison
This is looking less readable, so, no, I prefer that previous, which was
much clearer about slices. I can't even quite make the slices out in
these rules. (But thanks for the opportunity to try.)
More information about the Python-list
mailing list