473,395 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

operator.isMappingType

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.
Raymond Hettinger
Jul 18 '05 #1
3 1811

"Raymond Hettinger" <vz******@verizon.net> wrote in message
news:vg*******************@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

Jul 18 '05 #2
John Roth wrote:

"Raymond Hettinger" <vz******@verizon.net> wrote in message
news:vg*******************@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!


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
Jul 18 '05 #3

"Peter Hansen" <pe***@engcorp.com> wrote in message
news:3F***************@engcorp.com...
John Roth wrote:

"Raymond Hettinger" <vz******@verizon.net> wrote in message
news:vg*******************@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!


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
-Peter

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Paul Davis | last post by:
I'd like to overload 'comma' to define a concatenation operator for integer-like classes. I've got some first ideas, but I'd appreciate a sanity check. The concatenation operator needs to so...
1
by: joesoap | last post by:
Hi can anybody please tell me what is wrong with my ostream operator??? this is the output i get using the 3 attached files. this is the output after i run assignment2 -joesoap #include...
5
by: Jason | last post by:
Hello. I am trying to learn how operator overloading works so I wrote a simple class to help me practice. I understand the basic opertoar overload like + - / *, but when I try to overload more...
0
by: Martin Magnusson | last post by:
I have defined a number of custom stream buffers with corresponding in and out streams for IO operations in my program, such as IO::output, IO::warning and IO::debug. Now, the debug stream should...
3
by: Sensei | last post by:
Hi. I have a problem with a C++ code I can't resolve, or better, I can't see what the problem should be! Here's an excerpt of the incriminated code: === bspalgo.cpp // THAT'S THE BAD...
14
by: lutorm | last post by:
Hi everyone, I'm trying to use istream_iterators to read a file consisting of pairs of numbers. To do this, I wrote the following: #include <fstream> #include <vector> #include <iterator> ...
6
by: YUY0x7 | last post by:
Hi, I am having a bit of trouble with a specialization of operator<<. Here goes: class MyStream { }; template <typename T> MyStream& operator<<(MyStream& lhs, T const &)
5
by: raylopez99 | last post by:
I need an example of a managed overloaded assignment operator for a reference class, so I can equate two classes A1 and A2, say called ARefClass, in this manner: A1=A2;. For some strange reason...
3
by: y-man | last post by:
Hi, I am trying to get an overloaded operator to work inside the class it works on. The situation is something like this: main.cc: #include "object.hh" #include "somefile.hh" object obj,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.