Re: What is the difference between 'except IOError as e:' and 'except IOError, e:'

2009-11-18 Thread Marcus Gnaß
See also http://docs.python.org/dev/3.0/whatsnew/2.6.html#pep-3110-exception-handling-changes -- http://mail.python.org/mailman/listinfo/python-list

Re: What is the difference between 'except IOError as e:' and 'except IOError, e:'

2009-11-17 Thread MRAB
Peng Yu wrote: I don't see any different between the following code in terms of output. Are they exactly the same ('as' v.s. ',')? try: raise IOError('IOError') except IOError as e: print e try: raise IOError('IOError') except IOError, e: print e The second form is the old form. Later

Re: What is the difference between 'except IOError as e:' and 'except IOError, e:'

2009-11-17 Thread Steven D'Aprano
On Tue, 17 Nov 2009 20:28:16 -0600, Peng Yu wrote: > I don't see any different between the following code in terms of output. > Are they exactly the same ('as' v.s. ',')? > > try: > raise IOError('IOError') > except IOError as e: > print e This is the preferred syntax. It is used in Python 2

Re: What is the difference between 'except IOError as e:' and 'except IOError, e:'

2009-11-17 Thread Xavier Ho
On Wed, Nov 18, 2009 at 12:28 PM, Peng Yu wrote: > I don't see any different between the following code in terms of > output. Are they exactly the same ('as' v.s. ',')? > Yes, they're exactly the same. However, the syntax with "as" is newer, introducted in Python 3.x, and eventually backported t

What is the difference between 'except IOError as e:' and 'except IOError, e:'

2009-11-17 Thread Peng Yu
I don't see any different between the following code in terms of output. Are they exactly the same ('as' v.s. ',')? try: raise IOError('IOError') except IOError as e: print e try: raise IOError('IOError') except IOError, e: print e -- http://mail.python.org/mailman/listinfo/python-list