idioms for abstract base classes
Ben Wolfson
wolfson at uchicago.edu
Fri Apr 13 14:25:14 EDT 2001
In article <mailman.987183619.7370.python-list at python.org>, "Carlos
Ribeiro" <cribeiro at mail.inet.com.br> wrote:
> In Delphi, there is a "abstract" keyword that can be used as syntactic
> sugar as in the example below:
>
> class B:
> def __init__(self): abstract
> def dosomething(self): abstract
>
> ...where "abstract" will raise a "abstract method exception". Do anyone
> smells a PEP here <wink>?
You can already do:
class B:
def __init__(self): raise NotImplementedError
def dosomething(self): raise NotImplementedError
or even:
def _abstract(): raise NotImplementedError
class B:
def __init__(self): _abstract()
--
Barnabas T. Rumjuggler
Betty Botter bought an ice-cream sandwich. "But",
said she, "This ice-cream sandwich's messy! If I
put it in my pocket, it will make my pocket messy!"
More information about the Python-list
mailing list