whats this mean?
Sean 'Shaleh' Perry
shalehperry at home.com
Sat Jul 21 04:41:15 CEST 2001
On 21-Jul-2001 TheDustbustr wrote:
># BEGIN CODE BLOCK
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.bind((HOST, PORT))
> conn, addr = s.accept()
> except socket.error, why: ## reference 1
> print "Server Error: " + errno.errorcode[why] + ", " + why ##
> reference 2
># END CODE BLOCK
> what does reference 2 mean? what do those brackets do? And for reference 1,
> what will 'why' hold if an error occurs?
>From the language reference, 4.2:
When an exception is raised, an object (maybe None) is passed as the
exception's ``parameter'' or ``value''; this object does not affect the
selection of an exception handler, but is passed to the selected exception
handler as additional information. For class exceptions, this object must be an
instance of the exception class being raised.
See also the description of the try statement in section 7.4 and raise
statement in section 6.8.
For fun, write an exception handler:
except foo, e:
print e, e, e
Remember, the python interpreter can also be run interactively. It is a great
way to experiment and learn.
More information about the Python-list