On Fri, Dec 02, 2005 at 10:43:56AM +0100, bruno at modulix wrote:
> Inyeol Lee wrote:
> (snip)
> 
> >>>>class A(object):
> >>>>...     def __init__(self, foo):
> >>>>...             if self.__class__ is A:
> >>>>...                     raise TypeError("A is base class.")   
> 
> 
> s/TypeError/NotImplementedError/
> s/base class/abstract class/

I prefer TypeError here, NotImplementedError would be OK though.
Here is an example from sets.py in stdlib.


class BaseSet(object):
    """Common base class for mutable and immutable sets."""

    __slots__ = ['_data']

    # Constructor

    def __init__(self):
        """This is an abstract class."""
        # Don't call this from a concrete subclass!
        if self.__class__ is BaseSet:
            raise TypeError, ("BaseSet is an abstract class.  "
                              "Use Set or ImmutableSet.")


Inyeol
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to