Ideally, if we get the signature API that's been discussed, then lists and tuples and such would have a constraint on their __getitem__ method:
def __getitem__( self, index:int ): ... Thus, the concept testing code could look to see what types are acceptable to the __getitem__ method and make its decision based on that. Steven Bethard wrote: > On 5/11/06, Talin <[EMAIL PROTECTED]> 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 _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com