Chris Torek wrote:

> >>> import socket
> >>> isinstance(socket.error, IOError)
> False

Here you test if the socket.error *class* is an instance of IOError; this 
would print True if IOError were socket.error's metaclass. However:

>>> isinstance(socket.error(), IOError)
True

or more directly:

>>> issubclass(socket.error, IOError)
True
>>> issubclass(socket.error, EnvironmentError)
True

This is a relatively recent change:

$ python2.5 -c'from socket import error; print issubclass(error, IOError), 
issubclass(error, EnvironmentError)'
False False
$ python2.6 -c'from socket import error; print issubclass(error, IOError), 
issubclass(error, EnvironmentError)'
True True

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to