[Python-Dev] return type of complex (original) (raw)
Tres Seaver tseaver at palladion.com
Sat Oct 20 21:28:28 CEST 2012
- Previous message: [Python-Dev] return type of __complex__
- Next message: [Python-Dev] return type of __complex__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 10/19/2012 07:35 PM, Greg Ewing wrote:
Antonio Cuni wrote:
Traceback (most recent call last): File "", line 1, in TypeError: complex should return a complex object
i.e., the complex constructor does not check that complex returns an actual complex, while the cmath functions do. Looks to me like cmath is being excessively finicky here. Why shouldn't a float be usable in any context expecting a complex?
Exactly: float is perfectly Liskov-substituable for complex; only applications which do explicit type sniffing can tell the difference, which makes the sniffing bogus.
Tres. - --
Tres Seaver +1 540-429-0999 tseaver at palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
iEYEARECAAYFAlCC+1wACgkQ+gerLs4ltQ7S1QCfUjvUsmMiHuW8DDXue0HPzvXE Qv4Anissl8zNnx8KZyJQfcDxWlddTXGA =6KUH -----END PGP SIGNATURE-----
- Previous message: [Python-Dev] return type of __complex__
- Next message: [Python-Dev] return type of __complex__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]