Michael Chermside wrote: > Nick Coghlan writes: >> Close enough to on-topic to stay here, I think. However, I tend to think of >> the taxonomy as a little less flat: >> >> basecontainer (anything with __len__) >> - set >> - basemapping (anything with __getitem__) >> - dict >> - basesequence (anything which understands x[0:0]) >> - list >> - tuple >> - string >> - unicode >> - basearray (anything which understands x[0:0,]) >> - Numeric.array/scipy.array
<snip> > So I have a counter-proposal. Let's NOT create a hierarchy of abstract > base types for the elementary types of Python. (Even basestring feels > like a minor wart to me, although for now it seems like we need it.) Sorry - I meant to indicate that I didn't think the base classes were necessary because the relevant checks already existed in a "does it behave like one" sense: def is_container(x): try: len(x) return True except (TypeError, AttributeError): return False def is_mapping(x): return hasattr(x, "__getitem__") def is_sequence(x): try: x[0:0] return True except LookupError: return False def is_multiarray(x): try: x[0:0,] return True except LookupError: return False I agree it's a definite tangent to the original topic :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com