Doc bug? customize getslice, setslice

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Brewer

    Doc bug? customize getslice, setslice

    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.



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

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

    def __getslice__(se lf, i, j):
    return self[max(0, i):max(0, j):]
    def __setslice__(se lf, i, j, seq):
    self[max(0, i):max(0, j):] = seq
    def __delslice__(se lf, 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
    fumanchu@amor.o rg

Working...