on slices, negative indices, which are the equivalent procedures?

Dennis Lee Bieber wlfraed at ix.netcom.com
Wed Aug 11 18:32:03 EDT 2021


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).
"""

	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



-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/



More information about the Python-list mailing list