Help with Python Grammar change
Travis Oliphant
olipt at mayo.edu
Tue Feb 15 12:38:08 EST 2000
>
> Whether or not it's possible in this instance (and to be honest, this
> doesn't seem a particuarly useful change <wink> but that's just me), changes
> to the grammar shouldn't be undertaken lightly. Quite a few of us poor souls
> out there have Python eating programs of one sort or another and changes to
> the grammar can cause our programs to fail in baldness inducing ways.
I can understand this problem. The reason I'm interested is due to the
use of Python as a data analysis environment. There is a debate brewing
about whether or not slices of array objects should be references or
copies and I was hoping that it would be possible for a "function-call" to
produce copying behavior and "indexing" notation to continue with it's
current reference behavior.
If a is a 3-dimensional array currently
a[:,:,5] returns a reference to a two-dimensional sub-array.
It would be useful if a(:,:,5) returned a copy to that array. Using the
current grammar we could make a(slice(None),slice(None),5) return the
copy, but it is definitely not as clever.
>
> If I have to end up looking like a Benny Hill sidekick, it would be
> nice to know it was in the name of new functionality and not just
> getting-into-the-realms-of-another-language-beginning-with-P tiny
> syntactic sugar <wink>.
This is just an example of possible usage. It would allow many other
readability enhancments for array programmars as well.
-Travis
More information about the Python-list
mailing list