A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-January/051112.html below:

[Python-Dev] Exceptions *must*? be old-style classes?

[Python-Dev] Exceptions *must*? be old-style classes?Alex Martelli aleax at aleax.it
Sun Jan 16 10:47:34 CET 2005
On 2005 Jan 16, at 10:28, Martin v. Löwis wrote:

> Phillip J. Eby wrote:
>> Couldn't we require new-style exceptions to inherit from Exception?  
>> Since there are no new-style exceptions that work now, this can't 
>> break existing code.
>
> This would require to make Exception a new-style class, right?

Not necessarily, since Python supports multiple inheritance:

class MyException(Exception, object): .....

there -- a newstyle exception class inheriting from oldstyle Exception. 
  (ClassType goes to quite some trouble to allow this, getting the 
metaclass from _following_ bases if any).

Without inheritance you might similarly say:

class AnotherOne(Exception):
     __metaclass__ = type
     ...

> This, in itself, could break existing code.

Not necessarily, see my previous post.  But anyway, PJE's proposal is 
less invasive than making Exception itself newstyle.


Alex

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4