This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author josh.r
Recipients docs@python, josh.r, leewz, xiang.zhang
Date 2016-05-11.17:08:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1462986511.07.0.416278707361.issue27000@psf.upfronthosting.co.za>
In-reply-to
Content
bool is not enough of a special case to call it out without confusing the issue. No, the bool constructor is not actually called. But it will still behave as if it was called for all intents and purpose, it just skips the reference counting shenanigans for the actual True/False singleton objects. Drawing a distinction might make people worry that it wouldn't invoke __len__ or __bool__ as normal.

Similarly, for all intents and purposes, your mental model of the identity function is mostly correct (I suspect the wording meant to use "function" in the mathematical sense, but it works either way). Yes, it never actually calls a function, but that's irrelevant to observed behavior. Your only mistake is in assuming the function actually returns the specific values True or False; no filter function needs to return True or False, they simply evaluate for truth or falsehood (that's why filter's docs use "true" and "false" to describe it, not "True" and "False"). filter(str.strip, list_of_strings) is perfectly legal, and yields those strings that contain non-whitespace characters.
History
Date User Action Args
2016-05-11 17:08:31josh.rsetrecipients: + josh.r, docs@python, leewz, xiang.zhang
2016-05-11 17:08:31josh.rsetmessageid: <1462986511.07.0.416278707361.issue27000@psf.upfronthosting.co.za>
2016-05-11 17:08:30josh.rlinkissue27000 messages
2016-05-11 17:08:30josh.rcreate