Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of object oriented constructs in python?

Tags:

python

oop

How does python handle object oriented constructs such as abstract, virtual, pure virtual etc

Examples and links would really be good.

like image 603
gath Avatar asked Jun 15 '09 04:06

gath


1 Answers

An abstract method is one that (in the base class) raises NotImplementedError.

An abstract class, like in C++, is any class that has one or more abstract methods.

All methods in Python are virtual (i.e., all can be overridden by subclasses).

A "pure virtual" method would presumably be the same thing as an abstract one.

In each case you could attempt deep black magic to fight against the language, but it would be (generally speaking) exceedingly silly to do so.

I've striven to deal with the "etc" part in two books, a dozen videos, two dozen essays and PDFs and other presentations, and I can't spend the next few days summarizing it all here. Ask specific questions, and I'll be glad to try and answer!

like image 106
Alex Martelli Avatar answered Oct 21 '22 16:10

Alex Martelli