I'm not sure what exactly do you mean when you ask about virtual methods, as in Python all methods are virtual. And I'm also not sure why you are using _virtual_init
instead of __init__
… does simply renaming a method buy you something?
Update: Ah, I've got an idea. You probably did this to prohibit instantiation of your base class still keeping initialisation functionality in it. The answer here is: forcing things is not pythonic. Just document that this class is abstract (and probably call it AbstractSmth
).
Speaking about run-times errors. Python is a dynamic language, so, well, that's how it works. A common idiom is raising NotImplementedError
in __init__
to show that your class is abstract (and the same is true for abstract (pure virtual) methods). You can also have a look at abc
as it does what you want: it prohibits instantiation of abstract classes. But I also strongly suggest reading PEP-3119 to understand what Abstract Base Classes are and what they are not.
AFAIK, raising NotImplementedError
is enough for pylint to understand that your class/method is abstract.