[Python-3000] Making more effective use of slice objects in Py3k (original) (raw)
Delaney, Timothy (Tim) tdelaney at avaya.com
Mon Aug 28 01:52:08 CEST 2006
- Previous message: [Python-3000] path in py3K Re: [Python-checkins] r51624 - in python/trunk/Lib: genericpath.py macpath.py ntpath.py os2emxpath.py posixpath.py test/test_genericpath.py
- Next message: [Python-3000] Making more effective use of slice objects in Py3k
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 ...
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
- Previous message: [Python-3000] path in py3K Re: [Python-checkins] r51624 - in python/trunk/Lib: genericpath.py macpath.py ntpath.py os2emxpath.py posixpath.py test/test_genericpath.py
- Next message: [Python-3000] Making more effective use of slice objects in Py3k
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]