"Kay Schluehr" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > class A(object): > def __init__(self): > raise NotImplemented > > We can regard class A as a "pure abstract" class. It is impossible to > create instances of A.
You see that parameter 'self'? When __init__ is called, it is bound to an already created instance of A. How soon the last reference goes away I am not sure. If you change the raise statement to 'raise SomeException(self)', then that instance will become bound to the 'args' attribute of the resulting exception object. That exception object can in turn be get captured by an 'except SomeException, obj' statement. The binding of 'obj' persists after the except statement. To abort object creation, write a metaclass with __new__ and raise an exception there. > Thinking in Python makes live easier because we can not only > check interfaces superficially but we can inspect the code and we can > compare two code-objects on the behavioural level with a certain > accuracy. You are actually thinking in terms of the CPython implementation, not Python itself, which is fine as long as you don't expect CPython-specific introspection to work with other implementations. But it is pretty neat sometimes. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list