can i implement virtual functions in python ?

JCM joshway_without_spam at myway.com
Tue Sep 30 18:09:58 CEST 2003


Prabu <prabua at hotmail.com> wrote:
...
> I'm new to python, so excuse me if i'm asking something dumb. 
> Does python provide a mechanism to implement virtual functions?

Others have given good responses, but I'll jump in anyway.

Virtual functions (using C++ terminology) are something limited to
statically-typed languages.  A virtual function call will be resolved
dynamically, based on the runtime type of the object.  A non-virtual
call will be resolved at compile-time, based on the declared type of
the object.  Since Python is dynamically typed, the only possibility
is for all methods to be "virtual".




More information about the Python-list mailing list