FEEDBACK WANTED: Type/class unification

Guido van Rossum guido at python.org
Mon Aug 6 16:22:22 EDT 2001


dpt at abel.math.harvard.edu (Dylan Thurston) writes:

> The 'list' class/type has a method '__getslice__' (etc.), which uses
> the old and very broken interface.  I want to define a subclass for
> which this interface is insufficient.  If I want the new interface, I
> have to figure out how to hide that method.  [Does anyone know how to
> do this?]
> 
> Let me complain a little about the slicing interface while I'm at it.
> I don't understand why missing endpoints are turned into 0/maxint
> (rather than, say, 'None') before calling __getitem__; it removes a
> lot of flexibility.  Also, why are the slices restricted to being
> integers?  I can imagine, say, slicing a 2-dimensional array based on
> the endpoints (like 'delete-rectangle', etc. in Emacs).

Good point.  __getslice__ is ancient and should be banned.
Unfortunately, this is hard without breaking old code.  The best thing
to do might actually to simply not support __getslice__ etc. at all
for built-in types and subtypes thereof.  I'll have to think about
this more!

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-list mailing list