PEP 285: Adding a bool type

Laura Creighton lac at strakt.com
Wed Apr 3 11:45:50 EST 2002


> ["Mark McEahern]
> 
> I thought she was trying to make the stronger point that even without PEP
> 285, any function that is designed to return true/false (1/0) is badly
> designed.  Moreover, PEP 285 would only encourage people to write such
> functions.
> 
> Does that apply to, say, isinstance()?
> 
> // mark

That is more strongly worded then I would make it; I only think that
deciding that a function should be compelled to return only one of
two values requires long and careful deliberation.  This is because it
is likely that some day you will wish that you could provide more
information than this allows.  isinstance is a good example
of this. I would be pleased if isinstance returned more useful info
than just yes/no, such as : 0, no inheritance; 1: direct instance of the 
requested class; 2: instance of a subclass of the requested class.
90% of uses would still be yes/no, but this would be fine, and you would
get the extra information when you needed it.

Laura Creighton





More information about the Python-list mailing list