Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why exception is not newstyle class?

2 views
Skip to first unread message

kyo

unread,
Jan 5, 2004, 2:49:35 AM1/5/04
to
class A(Exception):

def __init__(self, n):
self.test = n

(1) :

class B(A):

def __init__(self, n):
#A.__init__(self, n)
super(B, self).__init__(n)
self.testb = n

try:
raise B, B(1)
except A, a:
print dir(a)

=============================
(2):

class B(object):
pass
class C(B):
pass
class D(C):
pass


for c in [B, C, D]:
try:
raise c()
except D:
print "D"
except C:
print "C"
except B:
print "B"

================================

I want to use new style class, how to do that?
If I can't, Why?

Jp Calderone

unread,
Jan 5, 2004, 8:13:46 AM1/5/04
to pytho...@python.org
On Sun, Jan 04, 2004 at 11:49:35PM -0800, kyo wrote:
>
> I want to use new style class, how to do that?
> If I can't, Why?

Because Exceptions existed before new-style classes did, and the mechanism
has not yet caught up.

Jp

0 new messages