Extension without sub-classing?
Jp Calderone
exarkun at intarweb.us
Mon Jun 2 22:38:04 EDT 2003
On Tue, Jun 03, 2003 at 02:17:35AM +0000, Martin d'Anjou wrote:
> Is it possible to extend a python class without sub-classing?
>
> For example, in file1.py
>
> class car:
> def start_engine(self):
> print "Started"
>
> And in file2.py, continue the declaration of the car class, without
> specializing it:
>
> extend car:
> def apply_breaks(self):
> print "You have stopped"
>
> I know the "extend" syntax is wrong, but I want to extend "car" without
> sub-classing. Is this possible and how?
http://intarweb.us:8080/evil/reopenable.py
Jp
--
"The problem is, of course, that not only is economics bankrupt but it has
always been nothing more than politics in disguise ... economics is a form
of brain damage." -- Hazel Henderson
More information about the Python-list
mailing list