operator.isMappingType

John Roth newsgroups at jhrothjr.com
Sat Nov 1 20:48:29 EST 2003


"Raymond Hettinger" <vze4rx4y at verizon.net> wrote in message
news:vgYob.46447$4O1.17443 at nwrdny01.gnilink.net...
> Since the advent of extended slicing, operator.isMappingType() returns a
> misleading result.
>
> >>> map(operator.isMappingType, ([], (), {}, '', u''))
> [True, True, True, True, True]
>
>
> I recommend removing it from the operator module.

I get the following on 2.2.3:

>>> map (operator.isMappingType,([], {}, (), ", u"))
[0, 1, 0, 0]

Where did the fifth True come from? That's really odd!

How much code would removing it break, versus
changing the test so it looked for one or more of the
methods that's unique to maps, and not to other
kinds of sequences? Granted, testing for something
other than a magic method would slow it down, but
that should be better than either leaving it broken,
or breaking otherwise innocent code.

John Roth



>
>
> Raymond Hettinger
>
>






More information about the Python-list mailing list