A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-November/039898.html below:

[Python-Dev] reflections on basestring -- and other abstractbasetypes

[Python-Dev] reflections on basestring -- and other abstractbasetypesAlex Martelli aleaxit at yahoo.com
Mon Nov 3 03:40:02 EST 2003
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


More information about the Python-Dev mailing list

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