[Python-Dev] return type of __complex__

Guido van Rossum guido at python.org
Sun Oct 21 01:48:05 CEST 2012


On Sat, Oct 20, 2012 at 12:28 PM, Tres Seaver <tseaver at palladion.com> wrote:
> Exactly:  float is perfectly Liskov-substituable for complex;  only
> applications which do explicit type sniffing can tell the difference,
> which makes the sniffing bogus.

You don't have to do explicit sniffing. You could also be catching
exceptions, e.g. ordering floats works, but ordering complex raises
TypeError.

All in all I'm still in favor of treating this as a new feature. It
would otherwise encourage people writing code "for Python 2.7" that
would actually break on older versions of 2.7. Yes, I'm aware that
every bugfix release makes *some* code work that was broken before.
But this is still different. "API X now supports argument type Y"
smells like a new feature to me, no matter what you substitute for X
and Y.

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list