Names changed to protect the guilty
Scott David Daniels
scott.daniels at acm.org
Sat Oct 7 13:35:13 EDT 2006
John Machin wrote:
> ... any function/method whose name begins with "has" or "is"
> returns an honest-to-goodness actual bool (or what passed for
> one in former times).
True for 75% of the builtins:
>>> import __builtin__
>>> sorted(nm for nm in dir(__builtin__)
if nm.startswith('is') or nm.startswith('has'))
['hasattr', 'hash', 'isinstance', 'issubclass']
>>> [hasattr(type,'mro'), hash(123), isinstance(type, type),
issubclass(type, type)]
[True, 123, True, True]
:-)
--Scott David Daniels
scott.daniels at acm.org
More information about the Python-list
mailing list