Difference between 'is' and '=='

Felipe Almeida Lessa felipe.lessa at gmail.com
Tue Mar 28 18:44:36 EST 2006


Em Ter, 2006-03-28 às 15:18 -0800, Ross Ridge escreveu:
[snip]
> Consider this example using the socket.IPPROTO_RAW constant:
> 
> >>> socket.getaddrinfo("localhost", None, socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)[0][2] is socket.IPPROTO_RAW
> False
> 
> >>> socket.getaddrinfo("localhost", None, socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)[0][2] == socket.IPPROTO_RAW
> True

Ok, you win. It's not safe to do "is" checks on these kinds of
constants.

-- 
Felipe.




More information about the Python-list mailing list