durusmail: durus-users: PersistentList.data_is
PersistentList.data_is
2007-11-05
2007-11-05
2007-11-05
2007-11-05
2007-11-05
2007-11-05
2007-11-05
PersistentList.data_is
Andrew Bettison
2007-11-05
Is there any reason why the PersistentList.data_is class attribute is
not used when instantiating the PersistentList.data instance attribute?

To be specific, here are the first lines of the PersistentList
definition:

    >>> class PersistentList (PersistentObject):
    ...     """
    ...     Instance attributes:
    ...       data : list
    ...     """
    ...     __slots__ = ['data']
    ...
    ...     data_is = list
    ...
    ...     def __init__(self, *args, **kwargs):
    ...         self.data = list(*args, **kwargs)

Shouldn't that last line be:

    ...         self.data = self.data_is(*args, **kwargs)

Other places where data_is should perhaps be used are __setslice__,
__add__, __radd__ and __iadd__.

The same question goes for PersistentDict.data_is and PersistentSet.s_is.

I ask because I want to use PersistentList to wrap my own subclass of
builtin list (Python 2.4+), and it would seem the best way to do it
would be:

    >>> class MyPersistentList(PersistentList):
    ...     data_is = MyList

But at the moment that would not work.

--
Andrew Bettison 
reply