operator.isMappingType

  • Thread starter Raymond Hettinger
  • Start date
J

John Roth

Raymond Hettinger said:
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
 
P

Peter Hansen

John said:
Raymond Hettinger said:
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!

Raymond used pairs of single quotes, while you used only
individual double-quotes surrounding a string containing
a comma, a space, and the letter u. His had an empty
string and an empty unicode string...

-Peter
 
J

John Roth

Peter Hansen said:
John said:
Raymond Hettinger said:
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!

Raymond used pairs of single quotes, while you used only
individual double-quotes surrounding a string containing
a comma, a space, and the letter u. His had an empty
string and an empty unicode string...

I see. That did look odd...

John Roth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top