Re: NameError vs AttributeError

2012-08-01 Thread Ethan Furman
Terry Reedy wrote: On 7/31/2012 4:49 PM, Chris Kaynor wrote: On Tue, Jul 31, 2012 at 1:21 PM, Terry Reedy wrote: Another example: KeyError and IndexError are both subscript errors, but there is no SubscriptError superclass, even though both work thru the same mechanism -- __getitem__. The

Re: NameError vs AttributeError

2012-08-01 Thread Terry Reedy
On 8/1/2012 11:53 AM, Ethan Furman wrote: Terry Reedy wrote: On 7/31/2012 4:49 PM, Chris Kaynor wrote: On Tue, Jul 31, 2012 at 1:21 PM, Terry Reedy wrote: one wants to catch both errors, one can easily enough. To continue the example above, popping an empty list and empty set produce

NameError vs AttributeError

2012-07-31 Thread Ulrich Eckhardt
Hi! Using Python 2.7, I stumbled across the fact that 'self.xy' raises an AttributeError if self doesn't have an 'xy' as attribute, but 'xy' will instead raise a NameError. To some extent, these two are very similar, namely that the name 'xy' couldn't be resolved in a certain context, but

Re: NameError vs AttributeError

2012-07-31 Thread Terry Reedy
On 7/31/2012 6:36 AM, Ulrich Eckhardt wrote: Hi! Using Python 2.7, I stumbled across the fact that 'self.xy' raises an AttributeError if self doesn't have an 'xy' as attribute, but 'xy' will instead raise a NameError. To some extent, these two are very similar, namely that the name 'xy'

Re: NameError vs AttributeError

2012-07-31 Thread Chris Kaynor
On Tue, Jul 31, 2012 at 1:21 PM, Terry Reedy tjre...@udel.edu wrote: Another example: KeyError and IndexError are both subscript errors, but there is no SubscriptError superclass, even though both work thru the same mechanism -- __getitem__. The reason is that there is no need for one. In

Re: NameError vs AttributeError

2012-07-31 Thread Terry Reedy
On 7/31/2012 4:49 PM, Chris Kaynor wrote: On Tue, Jul 31, 2012 at 1:21 PM, Terry Reedy tjre...@udel.edu mailto:tjre...@udel.edu wrote: Another example: KeyError and IndexError are both subscript errors, but there is no SubscriptError superclass, even though both work thru the same