How about "pure virtual methods"?

Fredrik Lundh fredrik at pythonware.com
Sun Dec 19 17:13:30 CET 2004


Alex Martelli:

>> what? Early warning, a few microseconds ahead of the invocation of a
>> method which will cause the stub in the base class to raise an
>> exception?
>
> Exactly.  Microseconds don't count, but stack levels do -- getting the
> traceback end as close as possible to the real CAUSE of the problem,
> rather than a few levels further down where the SYMPTOM appears, can
> easily shave whole minutes off debugging time.

minutes?

    Traceback (most recent call last):
    File "mymodule.py", line 9, in somefunction
        someobj.bar()
        ... zero or more lines ...
    File "somelibrary.py", line 3, in bar
        raise NotImplementedError("must implement abstract method bar")
    NotImplementedError: must implement abstract method bar

you have to look at the last line of a traceback to find the error message, and
the offending module/method is two lines above that.

> So, do _I_ use this?  Nah: I think abstract classes with
> explicitly-abstract "somebody's gotta implement this!" methods are
> rarely a good idea

yet you claim to be an expert on issues related to debugging NotImplemented-
Error exceptions?

</F> 






More information about the Python-list mailing list