[Python-3000] my take on "typeclasses"

Steven Bethard steven.bethard at gmail.com
Thu May 11 19:27:30 CEST 2006


On 5/11/06, Talin <talin at acm.org> wrote:
> sequence( indexable ):
>     -- an indexable in which the indexes are successive integers
>     -- Test: isinstance( index_type, int )

I think as of Python 2.5, this should be hasattr(index_type, '__index__'), no?

> mapping( indexable ):
>     -- an indexable in which the indices are hashable values:
>     -- Test: hashable( index_type )
>     -- (Also test for immutable if its feasible)

This seems all and good, but how do you figure out what "index_type"
is?  Are you suggesting that "indexables" which want to be identified
as sequences or mappings need to provide their index type somehow?  If
so, how?  (By inheriting from an abstract type?)

STeVe
-- 
Grammar am for people who can't think for myself.
        --- Bucky Katt, Get Fuzzy


More information about the Python-3000 mailing list