On Monday 03 November 2003 09:16 am, Raymond Hettinger wrote: ... > type and another builtin type. Does anyone other than you, me, Armin, > and Tim even use multiple inheritance? This basically never comes up I think you're not very acquainted with people coming from C++ or Eiffel... > > Yes, but isn't isSequenceType pretty iffy too...? > > Nope. > > >>> import operator > >>> map(operator.isSequenceType, [(), [], 'ab', u'ab', {}, 1]) > > [True, True, True, True, False, False] > > >>> map(operator.isMappingType, [(), [], 'ab', u'ab', {}, 1]) > > [True, True, True, True, True, False] > > The first is 100% correct. > The second has four false positives. Right: isSequenceType works on built-ins, isMappingType doesn't. > For user defined classes implementing __getitem__, neither function can > distinguish between a mapping or a sequence. This is the best they can > do. OK -- so, if we had basesequence and basemapping, the user COULD help make the distinction totally reliable (if multiply inheriting from both was allowed, the user could also make a total unusable muddle of course:-). Alex
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4