[Python-3000] Making more effective use of slice objects in Py3k
Delaney, Timothy (Tim)
tdelaney at avaya.com
Mon Aug 28 01:52:08 CEST 2006
Jim Jewett wrote:
> s[start:stop].find(prefix)
No matter what, I really think the obj[start:stop:step] syntax needs to
be consistent in its behaviour - either returning a copy or a view - and
that that behaviour be to return a copy. I'm not at all in favour of
sometimes getting a copy, and sometimes getting a view.
As a bit of an out-there and very premature suggestion ... <wink>
For when/*if* views ever become considered to be a good thing for
builtin classes, etc, may I suggest that the following syntax be
reserved for view creation:
obj{start:stop:step}
mapping to something like:
def __view__(self, slice)
So if you really want a string view, use:
s{1:2}
instead of:
s[1:2]
I don't *think* the syntax is currently legal, and I don't think it
could ever be ambiguous - anyone think of a case where it could be?
Tim Delaney
More information about the Python-3000
mailing list