Doc bug? customize getslice, setslice

R

Robert Brewer

I was writing a subclass of dict today, and read the 2.3.3 docs
regarding __getslice__, __setslice__, and __delslice__. The getslice
discussion says it's deprecated since 2.0. Setslice and delslice don't
have that disclaimer. However, the rest of the page seems to imply that
they are also deprecated. In particular, the example code at the bottom
of the page skips defining slice methods if the version is 2.0 or over.

http://www.python.org/doc/current/ref/sequence-methods.html

class MyClass:
...
def __getitem__(self, index):
...
def __setitem__(self, index, value):
...
def __delitem__(self, index):
...

if sys.version_info < (2, 0):
# They won't be defined if version is at least 2.0 final

def __getslice__(self, i, j):
return self[max(0, i):max(0, j):]
def __setslice__(self, i, j, seq):
self[max(0, i):max(0, j):] = seq
def __delslice__(self, i, j):
del self[max(0, i):max(0, j):]
...


Can someone confirm my theory that setslice and delslice are also
deprecated? Whether they are or not, I think that should be made more
clear, both in the discussion and the example code.

Should I file a doc bug?


Robert Brewer
MIS
Amor Ministries
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top